我认为Socket.IO应该选择寻找与服务器连接的最佳方法 在该系列中,
Websocket , FlashSocket and then JSONP
但是我的服务器在 Node 0.4.9(在使用cygwin编译的Windows上)之上运行socket.io 0.7.7,在没有任何明显原因的情况下进入XHR/JsonP轮询。我检查了 80 - 89 的所有端口只是为了确定,但问题始终相同。
我还检查了双方的控制台日志。 Firebug 没有给出错误,只是向我显示 XHR 获取请求。
在服务器控制台上它给了我:
info - socket.io started
debug - client authorised // i dunno why this is occuring though
info - handshake autorised 154845454664764
setting request Get/socket.io/1/xhr-polling/154845454664764
debug - setting poll timeout
。 。 。等等 大家有什么理由吗??
最佳答案
您可能正在使用 Firefox that has WebSockets disabled 的版本.
Warning: Among other things, a key reason WebSockets is currently disabled by default in Firefox 4 and 5 is the discovery of a security issue in the protocol's design. Using WebSockets in those versions of Firefox in a production environment is not recommended at this time. If you still wish to experiment with WebSockets, you may do so by opening about:config and setting the network.websocket.enabled preference to true. You will also need to set the network.websocket.override-security-block preference to true in order to allow initializing a WebSocket connection.
关于javascript - Socket.io 无缘无故地恢复到 XHR/JSONP 轮询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6881742/