Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout Error When Using remoteJoin in a Different Namespace #545

Open
kewang opened this issue Aug 26, 2024 · 0 comments
Open

Timeout Error When Using remoteJoin in a Different Namespace #545

kewang opened this issue Aug 26, 2024 · 0 comments

Comments

@kewang
Copy link

kewang commented Aug 26, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant