Skip to content

Redis stream adapter & socket.io-sticky #13

Description

@JojoRebondy

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions