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.
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.
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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With