How to update redis URL on fly

Aperta
#348 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
express, node.js, redis

Direzione di ricerca

No files or tests are named. Reproduce the shown server and client sequence with Redis on ports 6379 and 6378, then inspect how the adapter is replaced and how existing clients are tracked. Done should define a supported way to change the Redis URL without requiring clients to disconnect and reconnect.

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

Descrizione

question

Hello,

How can I update redis URL on fly ?

I use:
node 10.16.0
express 4.17.1
socket.io 2.3.0
socket.io-redis 5.2.0
socket.io-client 2.3.0

I try to replace with a new Adaptater and set it to socket server:
Server

var app = require('express')();
var http = require('http').createServer(app);
var io = require('socket.io')(http);
var redisAdapter = require('socket.io-redis');

//the old adaptater.
io.adapter(redisAdapter({ host: 'localhost', port: 6379 }));

http.listen(3000, () => {
   console.log('listening on *:3000');

   setInterval(() =>{
      io.emit('bar')
   }, 1000)

   setTimeout(() => {
      //the REDIS URL is updated, so I must update the Adaptater with the new URL of REDIS.
      io.adapter(redisAdapter({ host: 'localhost', port: 6378 }));
   }, 10000)
})

The redis instances in port 6378 and 6379 work.

My issue: after updated the REDIS URL, the clients socket.io (socket.io-client) don't receive the event bar (and any other events !)

Before to update the REDIS URL the clients had received the event bar.

Client

var io = require('socket.io-client')
var socket = io.connect('http://localhost:3000')
socket.on('bar', () => console.log('receive'))

After the update of REDIS URL, to receive this event, the clients socket.io must to disconnect and reconnect. (it's bad!)

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.