javascript - Socket.io 无缘无故地恢复到 XHR/JSONP 轮询

标签 javascript node.js socket.io

我认为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/

相关文章:

javascript - 按随机顺序比较字符串

javascript - 将多个相似的功能合并为一个

javascript - 有人可以使这个脚本更简单吗?

javascript - Mongoose(或 MongoDB)中的 TransientTransactionError 是什么?

node.js - Jade + express : Where does my client side Javascript go?

javascript - ejs <%- body %> 不工作

javascript - 带有 Superagent Access-Control-Allow-Origin 错误的 GET 请求

javascript - Flask-SocketIO 与 RabbitMQ 一起使用时未从前端接收消息

javascript - 检测 Socket.IO 处理程序中的事件类型

javascript - 如何从进入休眠状态的 WebSocket 客户端计算机或进入后台的应用程序恢复(iPad 上的 Safari)