socketcluster
socketcluster copied to clipboard
Global Redis Subscriber
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?
anybody to help?
socketCluster already does this for you, so you don't need node_redis
I'm not aware of it, can you point me how it is done?