1

When I connect to the node server on IE 8 under WinXP, the connect event is fired many times. When I do the same on Chrome under WinXP or IE 11 under Windows 7 the connect fires only once, as expected.

The client code:

if (that.debug && window.console) console.log('connecting to '+server_addr);
var socket = that.socket = io.connect(server_addr,{
    'reconnect' : false,
    'connect timeout' : 1000,
    'max reconnection attempts': 3
});

socket.on('connect', function(){
    if (that.debug && window.console) console.log('Socket.on event:  connect');
    cb.call(that,socket);
});

The output on IE 8 :

LOG: connecting to my_server.com
LOG: Socket.on event:  connect
LOG: Socket.on event:  connect
LOG: Socket.on event:  connect
LOG: Socket.on event:  connect
LOG: Socket.on event:  connect
LOG: Socket.on event:  connect
LOG: Socket.on event:  connect
LOG: Socket.on event:  connect

Anyone experienced this issue? any idea how to solve / debug this?

Kuf
  • 17,318
  • 6
  • 67
  • 91
  • 1
    You might be duplicating listeners. If it suits your design, try calling `socket.removeAllListeners()` before each emit. But I don't think the problem is within this code. Have any more? –  Mar 27 '14 at 22:29
  • The 'connecting to' error is displayed only once and there aren't any other places in the code where I connect or add more listeners without writing to the console, so I really don't think that this is the case. Morever, on other platforms / browsers the 'connect' is fired only once. Nevertheless I will try removing all listeners as you suggested just to varify that this is not the issue. – Kuf Mar 28 '14 at 06:59
  • possible duplicate of [Socket.IO and IE8 - jsonp-polling connections always failing](http://stackoverflow.com/questions/18637953/socket-io-and-ie8-jsonp-polling-connections-always-failing) – Paul Sweatte Jan 28 '15 at 18:17

1 Answers1

0

We continued experiencing this issue on some computers, I suspect it had to do with the WiFi router installed.

We finally got it resolved by upgrading to socket.io version 1.0:

if (that.debug && window.console) console.log('connecting to '+server_addr);
var socket = io.connect(server_addr);
socket.on('connect', function(){
    if (that.debug && window.console) console.log('Socket.on event:  connect');
    cb.call(that,socket);
});

Hope it will help anyone else having similar issues.

Kuf
  • 17,318
  • 6
  • 67
  • 91