Open
Description
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!)