socketio / socketio/socket.io

Socket.io client keeps disconnecting and reconnecting at a fixed interval because of ping timeout

Open
#5,117 20 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs investigation package:socket.io-client
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.
Screenshot_601

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

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.