socketcluster icon indicating copy to clipboard operation
socketcluster copied to clipboard

Global Redis Subscriber

Open ansubur opened this issue 6 years ago • 3 comments

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?

ansubur avatar Dec 15 '18 06:12 ansubur

anybody to help?

ansubur avatar Dec 17 '18 06:12 ansubur

socketCluster already does this for you, so you don't need node_redis

JoshuaVSherman avatar Dec 17 '18 17:12 JoshuaVSherman

I'm not aware of it, can you point me how it is done?

ansubur avatar Dec 18 '18 03:12 ansubur