Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE and Socket.io compatibility

I make some chat example like here: http://psitsmike.com/2011/09/node-js-and-socket-io-chat-tutorial/

When I use Chrome and Firefox everything works like a charm. With IE9 or Opera some socket.io events are not firing (e.g. disconnect) or firing too late, and data receiving is too slow.

I installed node.js and socket.io module with the npm method.

Please help.

like image 802
Vlatko Avatar asked Oct 20 '12 23:10

Vlatko


People also ask

Is WebSocket and Socket.IO different?

Socket.IO is built on top of the WebSocket protocol and provides additional capabilities such as automatic reconnections, broadcast support, or falling back to HTTP long polling. Note that Socket.IO uses Engine.IO under the hood to establish the low-level connection and exchange data between client and server.

Can I use Socket.IO with PHP?

For 'long-lived connection' , you can use Ratchet for PHP. It's a library built based on Stream Socket functions that PHP has supported since PHP 5. For client side, you need to use WebSocket that HTML5 supported instead of Socket.io (since you know, socket.io only works with node. js).


1 Answers

Socket.IO works best with websockets. Prior to 2012, most browsers did not support websockets (source).

With such browsers, socket.io falls back to various polling methods, but those may lead to problems you are experiencing, such as low data rate and delayed events (firing 1-2 minutes late). To remedy, this you should try to enable flash sockets.

 io.set('transports', [
     'websocket'
   , 'flashsocket'
   , 'htmlfile'
   , 'xhr-polling'
   , 'jsonp-polling'
 ]);

Also, make sure the flash policy port (default 10843) is reachable from the client.

like image 115
Martin Avatar answered Oct 21 '22 05:10

Martin