开发者

Socket.io reverting to XHR / JSONP polling for no apparent reason

I think Socket.IO should choose The best method to find connection with the server in the series ,

  Websocket , 
  FlashSocket  
  and then JSONP

but my server which is running socket.io 0.7.7 on 开发者_C百科the top of node 0.4.9 (on windows compiled with cygwin) goes to XHR/JsonP polling without any apparent reason. I have checked on all ports from 80 - 89 just to make sure , and the problem remains the same all the time.

I also checked for console logs in both the sides. Firebug Gives No error just shows me the XHR get requests instead.

and On the Server Console it gives me :

   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

. . . and so on Any reason in mind guys ??


You may be using a version of 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.


Firefox does have websockets disabled. Standard socket.io does not have flashsocket so you have to add it to your configuration =>

io.set('transports', [                     // enable all transports (optional if you want flashsocket)
    'websocket'
  , 'flashsocket'
  , 'htmlfile'
  , 'xhr-polling'
  , 'jsonp-polling'
]);

Then it should work just fine.


debug - client authorised  // i dunno why this is occuring though

socket.io can do authorization.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜