question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Network disconnect / offline mode not detected

See original GitHub issue

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.

window.addEventListener('offline', () => {alert('offline')});

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:

  • Device: Macbook Pro
  • OS: macOS 10.15.7
  • Browser: latest Chrome and Firefox

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
darrachequesnecommented, Feb 10, 2021

@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.

0reactions
darrachequesnecommented, Mar 12, 2021

This should be fixed by https://github.com/socketio/engine.io-client/commit/c361bc691f510b96f8909c5e6c62a4635d50275c, included in socket.io-client@4.0.0.

Thanks for the detailed bug report 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

SOLVED: Steam Stuck In Offline Mode Or Won't Go Online
Steam may occasionally fail to connect to the internet or become locked in offline mode. If you've recently encountered any of these issues, ......
Read more >
How to Fix Stuck Offline Mode Issue in Outlook?
Click the 'Work Offline' option to reset work offline mode and reconnect to the Exchange or mailbox server. Check the status. It should ......
Read more >
Troubleshoot when Nest Protect disconnects or is offline
5. Restart your router · Unplug your modem and router power cords. · Wait for 30 seconds, then plug your modem and router...
Read more >
Troubleshooting offline printer problems in Windows
1. Check to make sure the printer is turned on and connected to the same Wi-Fi network as your device · 2. Unplug...
Read more >
How to Fix the Outlook Disconnected Error on Windows
You can resolve the issue by disabling the offline mode. Select the Send/Receive tab at the top of the Outlook window. Select the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found