[Bug]: sharded pubsub uses wrong channel after joining a room with namespace

Aperta
#561 1 commento 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
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
redis, typescript

Direzione di ricerca

Inspect lib/util.ts around SPUBLISH and SSUBSCRIBE, then reproduce the namespace-and-room scenario described in the issue. Compare the Redis channels used after joining the room and when emitting to the socket; done means the emitted response uses the appropriate channel and is received by the client.

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

Descrizione

I have multiple socket io namespaces.

on client joins a specific namespace, the client will join a room under the namespace, after that server will send the client a message. Code:

ns!.on("connection", async (socket) => {
  console.log("A client connected!", socket.id);
  socket.join('Room 1')


  ns!.to(socket.id).emit("join_room_resp", {
    response: `Joined Room 1 successfully!`,
  });
});

Then I put some console.log in Redis adapter util under SPUBLISH and SSUBSCRIBE

export function SSUBSCRIBE(
  redisClient: any,
  channel: string,
  handler: (rawMessage: Buffer, channel: Buffer) => void
) {
  console.log(`>>>>>>SSUBSCRIBE ${channel}`);
  // ....
}

export function SPUBLISH(
  redisClient: any,
  channel: string,
  payload: string | Uint8Array
) {
  console.log(`SPUBLISH ${channel} ${payload}`);

  // ....
}

Output shows:

>>>>>>SSUBSCRIBE test.socket.io#/adasd#Room 1#
SPUBLISH test.socket.io#/adasd# {"type":3,"data":{"packet":{"type":2,"data":["join_room_resp",{"status":1,"room":"Room 1","response":"Joined Room 1 successfully!"}]},"opts":{"rooms":["x0jrTAQqgtKi7KDmAAAB"],"except":[],"flags":{}}},"uid":"19183eaa9eddca93","nsp":"/adasd"}

as shown above, after the user joins the channel, it subscribes Redis at channel test.socket.io#/adasd#Room 1#, but the message after that is published to channel test.socket.io#/adasd# which is wrong, and it lead to message never gets received

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.