Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Socket Counts and Retrieval Across Multiple Node Processes Using socket.io-redis-streams-adapter #29

Open
iakuf opened this issue Oct 14, 2024 · 0 comments

Comments

@iakuf
Copy link

iakuf commented Oct 14, 2024

I am using socket.io-redis-streams-adapter. Theoretically, when I connect to the same Redis-backed Socket.IO server from multiple Node processes, when I use io.sockets.adapter.sids.size to query the count, I find that the counts are different between the two processes. I am using a Koa service to connect and have attached io to the Koa context (ctx). There are two Node services behind an Nginx proxy. When I send requests to these two services, the response sizes are completely different. Have I used it incorrectly?

In multiple Node processes, I use the following method to check if a room exists and then retrieve the corresponding socket through ctx.io.sockets.sockets.get(socketId):

const members = ctx.io.sockets.adapter.rooms.get(roomid);
Does this mean that if I switch to another Node process, I cannot retrieve the socket in this way? In other words, is it not possible to use this method to determine if a socket exists?

Are ctx.io.sockets.adapter.rooms.get(roomId), ctx.io.sockets.sockets.get(socketId), io.sockets.adapter.rooms, and io.sockets.adapter.sids synchronized across multiple machines or Node processes after using redis-streams-adapter? What should I pay attention to when using them?

When ensuring that messages are always delivered reliably across multiple hosts or Node processes, can I only use io.to() with room names and not with individual socket.io instances?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant