Skip to content

socket.io + Angular SSR = ping timeout #5061

@Talb2005

Description

@Talb2005

Describe the bug

When using socket.io in an Angular project with Server Side Rendering enabled, the socket disconnects after 70 seconds (with default pingTimeout and pingInterval values).
Setting lower pingTimeout and pingInterval values will trigger the disconnects after a shorter time period.
This issue does not occur on socket.io version 4.3.2, but it does occur in version 4.4.0 and above.

To Reproduce

  1. Clone the Minimal Reproducible Example
  2. Run npm install to install the dependencies.
  3. Run npm run build:dev to build the project in development mode.
  4. Run npm run serve:ssr:dev to serve the project in development mode.
  5. Navigate to http://localhost:3000/ and open the developers console.
  6. Observe that "Socket disconnected after X seconds. Reason: ping timeout" is logged every pingTimeout + (pingInterval * 2)

Expected behavior
The socket should stay connected continuously.

Platform:

  • Device: macOS (but I believe this doesn't matter).
  • OS: macOS Sonoma 14.5 (but I believe this doesn't matter).

Additional context

  • If instead of the latest socket.io version (4.7.5) I install socket.io version 4.3.2 this issue doesn't occur. The socket stays connected as expected.
  • The issue does occur in socket.io versions 4.4.0 and above.
  • If I connect to a different socket.io server, which isn't part of the Angular SSR project, the issue doesn't occur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    to triageWaiting to be triaged by a member of the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions