Development/JavaScript
socket.io configure
linuxism
2012. 12. 18. 15:25
Connect -> Disconnect -> Connect doesn't work
The following code doesn't work for me:
socket = io.connect('http://host.com:8081');socket.disconnect();socket = io.connect('http://host.com:8081');
This is a workaround I've found:
socket = io.connect('http://host.com:8081');socket.disconnect();delete io.sockets['http://host.com:8081'];io.j = [];socket = io.connect('http://host.com:8081');
another
var base = 'http://localhost:3000'
, channel = '/chat'
, url = base + channel;
var socket = io.connect(url);
// call socket.disconnect() won't disconnect, so:
io.sockets[base].disconnect();
// reconnect syntax.
delete io.sockets[base]; io.j =[];
socket = io.connect(url);
note: socket.io version - 0.9.0, platform: windows 7 home premium
출처 - https://github.com/LearnBoost/socket.io-client/issues/251