ioredis (v3.2.2) doesn't seem to be listening to my Redis pub/sub events, and I'm not sure why
I'm starting a server that listens to incoming messages, as:
var Redis = require('ioredis');
redis.monitor(function (err, monitor) {
monitor.on('monitor', function (time, args, source, database) {
console.log(time + ": " + util.inspect(args));
});
});
redis.psubscribe('*', function(err, count) {
console.log("Listening to " + count + " channels.");
if(err){
console.log(err);
}
});
// republish any data received
redis.on('pmessage', function(subscribed, channel, message) {
console.log("pmessage: " + message);
});
When I run the above, the log output shows:
Listening to 1 channels.
When I publish a message into the redis server's queue, the log output shows:
1531403083.031496: [ 'SELECT', '0' ]
1531403083.036594: [ 'RPUSH',
'queues:myqueuename',
'{## JSON message body ##}' ]
So: I'm clearly connected to the server and receiving data, but I don't understand:
- Why the
monitor
callback isn't logging a PSUBSCRIBE or PUBLISH event, which is probably why: - The
pmessage
callback function isn't being fired
Any suggestions?
redis
object come from? I don't see it instantiated anywhere. – Asma Rahim Ali Jafri