SocketCluster / SocketCluster/socketcluster

Namespace in channels

Open
#592 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 have different apps that all use a shared socketcluster server for PubSub.

I want to separate each app's channel names to prevent conflicts so I can have the same channel names for different apps.

I tried to prefix the channel name with the app ID on the subscribe middleware on the server - something like app1/my-channel, app2/my-channel - but not luck.

I know that I can just subscribe to app1/my-channel channel from the client but in this case, it is not suitable for me and I want to let clients just subscribe to my-channel and the server handle the namespacing based on my client app.

How can I do namespace channels to achieve this or any other solution?

Here is my code that not working:

agServer.setMiddleware(
    agServer.MIDDLEWARE_INBOUND,
    async (middlewareStream) => {
        for await (let action of middlewareStream) {
            if (action.type === action.SUBSCRIBE) {
                    action.channel = `${appId}/${action.channel}`;
                }
            }
            action.allow();
        }
    }
);

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 by reading the inbound middleware setup around agServer.setMiddleware and the SUBSCRIBE action in the example. Trace whether changing action.channel can affect server-side channel routing, then determine whether the requested per-app namespacing is supported. Done means documenting a working approach or a clearly scoped implementation path for clients subscribing to my-channel.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.