Socket.io doesn't fire 'disconnect' until is misses a heartbeat
This means that with websockets, If the connection dies, the client isn't informed for up to 15 seconds. It'd be nice to get some kind of error message indicating that the underlying transport is having problems.
At the very least a way of checking the connection status so I don't send messages while the connection is down.
Its not the heartbeat but the closetimeout setting that causes this behavior.
~ Arnout Kazemier
On Sep 24, 2011, at 9:28 AM, Daniel [email protected] wrote:
This means that with websockets, If the connection dies, the client isn't informed for up to 15 seconds. It'd be nice to get some kind of error message indicating that the underlying transport is having problems.
At the very least a way of checking the connection status so I don't send messages while the connection is down.
Reply to this email directly or view it on GitHub: https://github.com/LearnBoost/socket.io-client/issues/304
Yes, I see that now.
In previous versions, 'disconnect' would fire immediately on websocket close so a client could respond with some useful UI if it chose to, now it may wait 15 seconds or more before it finds out the connection is dead. This is undesirable for something like a chat app.
Maybe your 'reopen' functionality will help this, allowing immediate reconnection.
Yeah, quite a few people are very frustrated at this change in behavior. It highly limits your ability to properly handle a lost connection, and I can't for the life of me understand how it could be seen as a step forward.
See https://github.com/LearnBoost/socket.io/issues/418
I already started making some changes about this in my personal branch, .disconnect() will now fire off the disconnect instantly without waiting for the close timeout to occur. But idk how we should handle a dropped connection, i still think it's best to wait until the closetimeout so we can try to reestablish the connection without having to create a new connection instance + new connection id.
On Sat, Sep 24, 2011 at 2:32 PM, 5HT2A < [email protected]>wrote:
Yeah, quite a few people are very frustrated at this change in behavior. It highly limits your ability to properly handle a lost connection, and I can't for the life of me understand how it could be seen as a step forward.
See https://github.com/LearnBoost/socket.io/issues/418
Reply to this email directly or view it on GitHub:
https://github.com/LearnBoost/socket.io-client/issues/304#issuecomment-2186154
It's somewhat frustrating now because with v7 we have two levels of connection (socket.io and the underlying transport) We have auto-reconnection for the socket.io level, but not for the underlying transport. I think the old methodology was simpler (only one connection layer) because now we are forced to re-implement reconnection on each layer.
Waiting for the closeTimeout with no feedback from socket.IO is NOT an option, that leaves the client with no way to tell if it's actually connected or not.
Seems like we have a three options:
- Have another event like
connectionSuspendedthat fires the instant the underlying transport is disconnected and then fireconnectionResumedwhen reconnection happens before thecloseTimeout. - Ditch the idea of separate connection layer state and make a transport disconnection initiate a real socket.io disconnection just like previous versions.
- Keep the
closeTimeout, and flesh out the connection state for the underlying transports, issuing events like "transportDisconnected" and "transportConnected" and handle auto reconnection in a similar (though simpler) manner as the socket.io layer.
Note: previous versions of Socket.IO were so stable that my socket.IO connection was my defacto "Am I connected to the internet" test.
I've fixed this issue, please see pull request https://github.com/LearnBoost/socket.io-client/pull/315
My pull request (above) was merged into master, so this is fixed.