我正在使用node-redis
。一切正常。我只订阅specific
频道。但我收到来自各个渠道的消息:
socket.on('connection', function(client) {
const subscribe = redis.createClient(6379, '127.0.0.1')
subscribe.psubscribe('tracking_*');
subscribe.on("error", function (err) {
console.log("Error " + err);
});
subscribe.on("pmessage", function(pattern, channel, message) {
client.send(message);
log('msg', "received from channel #" + channel + " : " + message);
});
client.on('message', function(msg) {
log('debug', msg);
});
client.on('disconnect', function() {
log('warn', 'disconnecting from redis');
subscribe.quit();
})
socket.on('connect', function(data){
setStatus('connected');
socket.emit('subscribe', {channel:'tracking_hi'});
});
正如您所看到的,我只订阅了tracking_hi
频道,但我收到了来自所有频道的消息。有什么问题?