Closed startmaster closed 3 years ago
Configure the key
option when instantiating. It defaults to 'socket.io'
@md-seb is right, you can use a different key
for each Socket.IO server:
Server A
const io = require('socket.io')(3000);
const redisAdapter = require('socket.io-redis');
io.adapter(redisAdapter({ host: 'localhost', port: 6379, key: 'socket.io' }));
Server B
const io = require('socket.io')(3000);
const redisAdapter = require('socket.io-redis');
io.adapter(redisAdapter({ host: 'localhost', port: 6379, key: 'custom' }));
And then the emitter instances:
const emitter1 = require('socket.io-emitter')({ host: '127.0.0.1', port: 6379, key: 'socket.io' }); // default value
const emitter2 = require('socket.io-emitter')({ host: '127.0.0.1', port: 6379, key: 'custom' });
Several servers use the same redis,but db is different.How can one server send to all its clients but not other servers' clients? I test it.For example,i send message in server A,but server B‘s clients receive this message.Because A and B use the same redis