Timeout Error When Using remoteJoin in a Different Namespace

Aperta
#545 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
redis, typescript

Direzione di ricerca

Reproduce the setup with the main and /bbb namespaces, Redis, and the remoteJoin calls described in the issue. Start at the remoteJoin implementation referenced by dist/index.js:417 and trace how namespace responses are handled. Done means remoteJoin completes for both namespaces without the timeout error, with coverage for this reproduction.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
2.8k
Fork
485
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di socketio/socket.io-redis-adapter

Tutte le issue di socketio/socket.io-redis-adapter

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.