socketio / socketio/socket.io-sticky

Redis stream adapter & socket.io-sticky

Open
#13 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
45
Forks
13
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm trying to use socket.io-sticky library with a socket.io Redis stream adapter.

My use case is the following, I have several severs (A & B) and I have several worker on each server.
I saw the following picture on your README.md and it feels like it's exactly my use case.

image

I tried implementing both library like such:

on the worker side:

const httpServer = Http.createServer(); const io = new Server(httpServer); io.adapter(createAdapter(redis)); setupWorker(io);

on the primary side:
` const httpServer = http.createServer();

setupMaster(httpServer, {
    loadBalancingMethod: "least-connection"
});
httpServer.listen(3000);`

I'm not using Express but directly the node internal Http library.

When I start the application I get no errors (all the setup part seems to be working fine) but whenever I create a websocket connection I get this error that crashes my application:

`node:internal/assert:14
throw new ERR_INTERNAL_ASSERTION(message);
^

Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

at new NodeError (node:internal/errors:405:5)
at assert (node:internal/assert:14:11)
at ServerResponse.detachSocket (node:_http_server:294:3)
at resOnFinish (node:_http_server:984:7)
at ServerResponse.emit (node:events:514:28)
at onFinish (node:_http_outgoing:1005:10)
at afterWrite (node:internal/streams/writable:507:5)
at afterWriteTick (node:internal/streams/writable:494:10)
at process.processTicksAndRejections (node:internal/process/task_queues:81:21) {

code: 'ERR_INTERNAL_ASSERTION'
}

Node.js v20.5.1
`

I don't really understand what I'm doing wrong so I'm just curious if implementing socket.io-stiky with a redis stream adapter is doable or not.

If anyone have any informations regarding the subject, it would be greatly appreciated.

Thanks in advance.

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 reproducing the crash with socket.io-sticky's setupWorker and setupMaster, the Redis stream adapter, direct Node HTTP servers, and Node.js v20.5.1. Trace the websocket connection until Node's ServerResponse.detachSocket assertion occurs. Done means determining whether this combination is supported and documenting the cause or a reproducible fix.

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
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.