web-socket-js
web-socket-js copied to clipboard
Fetching policy file error connecting to wss endpoint
I run into a SecurityError: Error #2048
when connecting to a wss endpoint:
https://rawgit.com/leeyeh/js-realtime-sdk/issue/web-socket-js/demo/web-socket-js/fail.html
[WebSocket] debug enabled
[WebSocket] policy file: xmlsocket://rtm51.leancloud.cn:843
[WebSocket] cannot connect to Web Socket server at wss://rtm51.leancloud.cn:6799/ (SecurityError: Error #2048)
make sure the server is running and Flash socket policy file is correctly placed
Error: Error #1009
[WebSocket] closed
However, if I connect to the same domain over ws:
first, everything works fine.
https://rawgit.com/leeyeh/js-realtime-sdk/issue/web-socket-js/demo/web-socket-js/success.html
[WebSocket] debug enabled
[WebSocket] policy file: xmlsocket://rtm51.leancloud.cn:843
[WebSocket] connected
[WebSocket] request header:
GET / HTTP/1.1
Host: rtm51.leancloud.cn:6779
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: ZFFqaXF7LRtYUSwHLkxqZg==
Origin: https://rawgit.com
Sec-WebSocket-Version: 13
[WebSocket] connected
[WebSocket] starting SSL/TLS
[WebSocket] request header:
GET / HTTP/1.1
Host: rtm51.leancloud.cn:6799
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: Gh9eWEMOZl82cy8cVXpsWA==
Origin: https://rawgit.com
Sec-WebSocket-Version: 13
[WebSocket] response header:
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: loOb+6xIG/TLyLrQkiINFZ3xKFk=
Event {isTrusted: false}
[WebSocket] response header:
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: WTRZwWqWWbaPIp35Zg5NNbo8as0=
Event {isTrusted: false}
The policy file is served correctly:
echo "<policy-file-request/>" | nc rtm51.leancloud.cn 843
<cross-domain-policy><allow-access-from domain="*" to-ports="*" /></cross-domain-policy>%
Hmm that's weird, but I have no idea why. Have you confirmed that it works fine without WEB_SOCKET_FORCE_FLASH?
Yes, it works with native WebSocket implement.
Hi guys, same problem. Have you found any solution for this?
save problem.please tell me why?