socket.io-client
socket.io-client copied to clipboard
When client restore connection, will have multiple connections
You want to:
- [x] report a bug
- [ ] request a feature
Current behaviour
I'm testing on Samsung J7, Android 8.0, cordova -WebView. socket.io version: 1.7.2.
After socket.io connection lost, and then wifi restore, socket.io will restore too. But sometimes, it will result to several connection, and i expect to only 1 connection. Sometimes, there are 10 restored connections. Although only 1 connection will be kept at last, but this is not expected.
Steps to reproduce (if the current behaviour is a bug)
Testing on Samsung J7, Android 8.0, cordova -WebView. socket.io version: 1.7.2.
- Start the client on webview
- stop wifi, to stop the socket.io connection
- Restore wifi 1 minutes later
- check connections from the server after client connection restored
Actual Result: there will be multiple connections from server side. And will only keep 1 connections about 1 minute later
Expected behaviour
Only see 1 connection from server side
Setup
- OS: Windows
- browser: Chrome
- socket.io version: 1.7.2
Other information (e.g. stacktraces, related issues, suggestions how to fix)
I am having a similar issue, that my emitted messages during connection lost get send randomly. Did you figure out something?
Feels like a typical HTTP/1.1 problem, that when a connection is lost and then restored, there isn't a great way to know if it's a new device connecting to the server, or an existing one that restores the connection. I suspect that your IP changed during the wifi reboot, some ISP do that and would change how server see clients.
@Chopinsky , thanks for your replay. But i'm sure, the IP not changed, I do have logs in the server side, even the session-id(I use session for socket.io authentication) is not changed.
Has anyone resolved the problem?It occured to me for several times.I have no idea till now.
Has anyone resolved the problem? same here
For future readers:
This is expected, because the server may not be aware of the client disconnection right away. It will eventually be aware of the disconnection once the heartbeat for the previous connection fails, which may take up to 45 seconds (pingInterval (25s) + pingTimeout (20s)
).
Reference: https://socket.io/docs/v4/server-options/#pinginterval