Skip to content
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 change results in incorrect connection status on the client. #4843

Open
akilude opened this issue Sep 29, 2023 · 2 comments
Open

Network change results in incorrect connection status on the client. #4843

akilude opened this issue Sep 29, 2023 · 2 comments

Comments

@akilude
Copy link

akilude commented Sep 29, 2023

Describe the bug
This happens when a user changes the network on the fly. When switching networks, the socket.io client goes from connected to disconnected to reconnected state. But the actual socket does not send or receive data for a lot longer (normally 30-45 seconds)

Additional info: The socket.io server is behind nginx.

To Reproduce

  1. Client side, connect to the socket.io server
  2. Switch networks (If you have multiple Wifi networks, you can switch to another network, on phone you can switch between wifi and cellular network)
  3. Sometimes the socket.io client emits the disconnected event
  4. After the network is changed, normally in less than 5 seconds the reconnect event is emitted
  5. The socket is not actually connected, messages cannot be sent/received from the server, messages are instead queued, normally after 30-45 seconds post the reconnect event, messages start flowing as usual.

Please fill the following code example:

Socket.IO server version: 4.7.2
Socket.IO client version: 4.7.2

Expected behavior
The client socket must be actually connected when it emits the reconnect event.

On a slightly off topic note, v4 of socket.io has been a joy to develop with. Thank you to all socket.io maintainers.

@akilude akilude added the to triage Waiting to be triaged by a member of the team label Sep 29, 2023
@darrachequesne
Copy link
Member

On a slightly off topic note, v4 of socket.io has been a joy to develop with. Thank you to all socket.io maintainers.

Thanks a lot for the kind words ❤️

Regarding your issue, I was not able to reproduce when switching from wifi to 4G (Chrome 117, Android):

az_recorder_20231002_225851.mp4

The client reconnects right away and receives "pong" events from the server.

Does it happen on all platforms?

@darrachequesne darrachequesne added needs investigation and removed to triage Waiting to be triaged by a member of the team labels Oct 2, 2023
@akilude
Copy link
Author

akilude commented Oct 3, 2023

I will create a minimal example and share here.

Have tested on Android chrome 117, and Mac chrome 117.

One small change is that i have only one network interface open at a time. So the device has wifi on, cellular data off, then i switch off wifi and turn on cellular data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants