Skip to content

Timeout Error When Using remoteJoin in a Different Namespace #545

@kewang

Description

@kewang

We're encountering a timeout error when attempting to use the remoteJoin function from the socket.io-redis adapter. The error occurs when a client initially connects to the default (main) namespace, and the server tries to have the client join a room in the /bbb namespace using remoteJoin.

server code

const io = SocketIOServer(port, {
  allowEIO3: true,
  cors: {
    origin: [
      'https://example.com'
    ],
    methods: ['GET', 'POST'],
    credentials: true
  }
});

io.adapter(
  redisAdapter('redis-url', {
    auth_pass: 'redis-password',
    requestsTimeout: 3000
  })
);

io.on("connection", async socket => {
  io.of("/").adapter.remoteJoin(socket.id, "room-1");

  io.of("/bbb").adapter.remoteJoin(socket.id, "room-1");
});

client code

const socket = io();

server error log

2024-08-25T17:56:42.260288+00:00 app[web.1]: [3131] SOCKETIO join error
2024-08-25T17:56:42.260543+00:00 app[web.1]: Error: timeout reached while waiting for remoteJoin response
2024-08-25T17:56:42.260546+00:00 app[web.1]: at Timeout._onTimeout (/app/node_modules/socket.io-redis/dist/index.js:417:28)
2024-08-25T17:56:42.260555+00:00 app[web.1]: at listOnTimeout (node:internal/timers:557:17)
2024-08-25T17:56:42.260555+00:00 app[web.1]: at processTimers (node:internal/timers:500:7)

Steps to Reproduce

  1. Connect a client to the main namespace using const socket = io();.
  2. On the server side, use remoteJoin to join the client to a room in both the main (/) and /bbb namespaces.
  3. Observe the timeout error in the server logs.

Expected Behavior

The client should successfully join the specified room in both namespaces without encountering a timeout error.

Actual Behavior

The remoteJoin operation times out when attempting to join the room in the /bbb namespace.

Additional Information

We are using the socket.io-redis adapter with a Redis server.
The issue seems related to using remoteJoin across different namespaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions