I use node_redis to subscribe to a channel which then publishes to all the subscribed clients
The below code is inside worker.js & SC runs 4 worker process.
var RedSubclient = redis.createClient(6379, '127.0.0.1');
RedSubclient.psubscribe(subChannelName);
RedSubclient.on("pmessage", function(pattern, channel, message){
scServer.exchange.publish(channel, message);
});
The issue is that, this code receives & publishes each message 4 times.
Looks like the Redisclient should be used globally, but I don't have clear idea how to do it.
Can anyone share a snippet?
I use node_redis to subscribe to a channel which then publishes to all the subscribed clients
The below code is inside worker.js & SC runs 4 worker process. var RedSubclient = redis.createClient(6379, '127.0.0.1'); RedSubclient.psubscribe(subChannelName); RedSubclient.on("pmessage", function(pattern, channel, message){ scServer.exchange.publish(channel, message); });
The issue is that, this code receives & publishes each message 4 times. Looks like the Redisclient should be used globally, but I don't have clear idea how to do it. Can anyone share a snippet?