Socket.io client keeps disconnecting and reconnecting at a fixed interval because of ping timeout
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 63.2k
- Forks
- 10.3k
- Avg merge
- 11d 20h
- Merged PRs (30d)
- 2
Description
Recently I've updated my socket.io server and client to 4.6.1 and ever since then my client keeps disconnectiong and reconnecting at a fixed interval. The disconnection reason on the client is ping timeout...
It does not matter whether the tab is in the foreground or background.
I cannot reproduce this issue on localhost.
I still have a client that uses 2.2.0 and it does not reconnect at all and seems to be working correctly.
Left is 2.2.0, right is 4.6.1. They both connect to the same server.
And more importantly the 4.6.1 client receives the ping (2) and sends the pong (3) message to the server, but it does not seem to matter.
Socket.IO server version: 4.6.1
Server
this.io = new Server(httpServer, {
allowEIO3: true,
serveClient: false
});
Socket.IO client version: 4.6.1
Client
this.socket = io(url, {
transports: ['websocket'],
reconnection: true,
reconnectionAttempts: 50,
reconnectionDelay: 5000,
reconnectionDelayMax: 25000,
auth: {
token: *****
}
});
Expected behavior
I expect the 4.6.1 client not to reconnect at a fixed interval.
Platform:
I can reproduce with:
- Chrome Version 113.0.5672.127 (Official Build) (64-bit)
- Firefox 113.0.1 (64-bit)
- Microsoft Edge Version 113.0.1774.50 (Official build) (64-bit)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file, test, or entry point is named. Start by comparing the 2.2.0 and 4.6.1 client ping/pong behavior using the supplied server and client configurations, then investigate why the newer client reports a ping timeout despite receiving and sending the heartbeat messages. Done means identifying the cause and preventing the fixed-interval disconnect and reconnect.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100