Skip to content

Network disconnect / offline mode not detected #1433

@hyperknot

Description

@hyperknot

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions