-
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
Network disconnect / offline mode not detected #1433
Comments
As a workaround, is there a way to force-send a ping event? |
So far I came up with this workaround, this seems to work.
How do everyone else handle this problem? |
@dverzolla I don't think this is fixed yet. @hyperknot I could indeed reproduce, thanks. That's really weird, one could expect that the TCP connection would be closed when the network is turned off, but that does not seem to be the case. |
The connection will be closed once the "offline" event is emitted by the browser, in order not to wait for the heartbeat mechanism to detect the disconnection. Reference: https://developer.mozilla.org/en-US/docs/Web/API/Window/offline_event Related: socketio/socket.io-client#1433
This should be fixed by socketio/engine.io-client@c361bc6, included in Thanks for the detailed bug report 👍 |
Describe the bug
When turning off the wireless network on my MacBook, the client does not detect the disconnect event. It waits a possibly long time until the ping detects it. Using Websockets.
To Reproduce
Any basic example will replicate it, for example https://socket.io/demos/chat/ replicates it.
Server
Does not matter, it is disconnected on the client.
Socket.IO client version:
3.0.4
Client
Default options, only
auth
is specified in options.Expected behavior
A clear and concise description of what you expected to happen.
When disconnecting the network, the socket should detect a disconnect event.
The browser correctly recognizes such event, the following triggers immediately.
navigator.onLine
is also correctly showing false.However SocketIO client believes it is still connected, the WS connection is sending messages like everything was connected. Only after the next ping event it recognizes that something is wrong and fires the disconnect event.
Platform:
The text was updated successfully, but these errors were encountered: