当我在WinXP下连接IE 8上的节点服务器时,多次触发connect
事件。当我在WinXP下的Chrome或Windows 7下的IE 11上执行相同操作时,connect
仅按预期启动一次。
客户端代码:
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);
});
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
有人遇到过这个问题吗?任何想法如何解决/调试这个?
答案 0 :(得分:0)
我们在某些计算机上继续遇到此问题,我怀疑它与安装的WiFi路由器有关。
我们最终通过升级到socket.io版本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);
});
希望它能帮助其他有类似问题的人。