-
Notifications
You must be signed in to change notification settings - Fork 3k
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_failed doesn't fire #375
Comments
I am also not receiving a connect_failed event, calling io.connect with a nonsense path and the same options. Using the latest socket.io from NPM (version 0.9.0) with Chrome 17 in OSX. Edit: just upgraded to version 0.9.1-1 via NPM, and added logging to ensure that this version is being used (which it is) - same result, no connect_failed event fired. Edit2: After digging around the source for a while, I happened upon the "error" event. It seems that in most cases when a connection fails, the error event is triggered instead of connect_failed. Looks like connect_failed is reserved for specific cases such as when the connection succeeds but the handshake fails, when an error packet is received with reason=='unauthorized', and perhaps others. So the "solution" to this is to subscribe to the "error" event (as well as 'connect_failed'). In my app, I translate the error event into 'Error connecting to server', while connect_failed shows 'Connection failed; try refreshing the page'. I'm not yet sure if this is correct or even adequate, but until I get a chance to test these situations, I think it'll do. |
I can confirm that getting a handler for the 'error' event solves at least part of this problem. |
However, the connect_failed doesn't seem to appear.
I've tried with the latest released socket.io-client (0.8.7) also with the latest released socket.io (0.8.6).
I've seen an approved pull request which was related to this, and I'm pretty sure it's in the version I have.
The text was updated successfully, but these errors were encountered: