SocketCluster / SocketCluster/socketcluster

Global Redis Subscriber

Open
#463 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
6.2k
Forks
318
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Redis subscriber code in worker.js and trace how it is launched across the four worker processes. Reproduce a publish with multiple workers and determine the intended subscription behavior; done means each message is published to subscribed clients once rather than once per worker.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, redis
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.