IE and Socket.io compatibility

2019-03-28 12:01发布

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.

1条回答
Melony?
2楼-- · 2019-03-28 12:59

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.

查看更多
登录 后发表回答