New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connect -> Disconnect -> Connect doesn't work #251
Comments
Same issue here -- was unable to connect-disconnect-reconnect the way you described. However, I've found that the following works. Oddly, if you omit the setTimeout and reconnect immediately (or after too short a timeout) then you are immediately disconnected.
|
socket = io.connect(host); |
I had the same issue so I could not finish my node knockout entry in time due to this bug :( |
None of the above workarounds worked for me. Guys, this is serious show stopper. Why the "Unable to reproduce" tag? My testing env. is latest Chrome on OS X 10.6. |
I am seeing the same thing. Also calling |
Use this one: |
How convenient, and ugly. What about removing |
Unfortunately, same problem here. You can not reconnect after disconnection. Only thing that worked for me after disconnection: Edit: it is not only one problem of the client-side disconnect(). It does not clean up data structures on disconnect - you can see that SocketNamespace.$events still has all callbacks for closed connections, etc. |
@mrjoes Use |
All right, is this really the final API for reconnecting? Rather strange. |
@skrat I agree with you. there should be an |
I don't think so, |
@milani: and leak memory due to orphaned sockets, event handlers, etc staying in io.sockets[]? Not very good idea to be honest. |
Nevermind, it won't add socket to io.sockets[] if you pass 'force new connection'. Though, it is a bit ugly, especially with endpoints, because you're losing multiplexing - it relies on socket in io.sockets to do multiplexing. |
@Gorokhov suggestion of using reconnect through the socket prototype worked well for me: |
Same issue here - socket.reconnect() isn't working for me, I'll try a few other workarounds. This is disappointing though, its a pretty basic piece of functionality to break in an update. I"m sure a lot of applications are unable to easily update because of this. If devs need any assistance reproducing the issue, I'm happy to help - i'm surprised to see the "unable to reproduce" tag on this bug. |
ah, great news :-) |
@wackfordjf3 Hey thanks, good call. Works now. :) |
Still facing issues with reconnect. socket = io.connect(url{'reconnect':false});socket.disconnect;// 1st disconnect Am on : socket.io@0.8.7 Further to this : |
Face the same thing as people already have here; even weird in namespace scenario. Drop the solution for namespacing: var base = 'http://localhost:3000' var socket = io.connect(url); // call socket.disconnect() won't disconnect, so: // reconnect syntax. note: socket.io version - 0.9.0, platform: windows 7 home premium |
spent an afternoon wrestling with unit tests that were timing out because I couldn't connect after disconnecting. {'force new connection':true} resolved the issue. thanks @milani |
It works for me! Thanks @mrjoes. |
Thanks @milani |
The 'force new connection' setting is now called 'forceNew' in the v1.0 release for those that might have run into this issue again. |
I pushed a commit to add BC with that, so soon no one should have this issue anymore! |
it worked 4 me, socket = io.connect(socketUrl,{'forceNew': true }); |
forceNew disables the whole namespace multiplexing system, is that really the solution? |
I'm using: |
Client.prototype.connect = function() {
if (!this.connection) {
this.connection = this.socket.connect(config.host + ':' + config.port);
}
else {
if (!this.connection.connected) {
this.connection.connect();
}
}
}; |
this solve my problem, thank you mr. milami |
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');
The text was updated successfully, but these errors were encountered: