[英]socketio inter server communication with redis and haproxy
I'm working on a project which uses SocketIO and should be Horizontally scalable. 我正在使用SocketIO的项目中,并且应该可以水平扩展。 Im using
我正在使用
I'm able to redirect my incoming Socket connections to Node servers using roundrobin method. 我可以使用roundrobin方法将传入的Socket连接重定向到Node服务器。 Socket connection is stable and if I use socket.emit() I'm receiving the data.
套接字连接是稳定的,如果我使用socket.emit(),我正在接收数据。 I'm also able to emit to the Other socket connection connected to the same Node server.
我还可以发出连接到同一节点服务器的其他套接字连接。
I'm facing issue in the following scenario: 我在以下情况下面临问题:
User A connected to Node server 1 and User B connected to Node Server 2 用户A连接到节点服务器1,用户B连接到节点服务器2
My intention is to store the Socket data in redis 我的意图是将套接字数据存储在Redis中
If User A wants to send some data to User B, how can I tell the Node server 2 to emit the data to User B from Node server 1 如果用户A要向用户B发送一些数据,如何告诉节点服务器2从节点服务器1向用户B发送数据
Please let me know how can I achieve this (with ref if possible). 请让我知道如何实现此目标(如果可能,请提供参考)。
Thanks in advance. 提前致谢。
Have a look at socket.io Redis adapter . 看一下socket.io Redis适配器 。 It should be exactly what you need.
它应该正是您所需要的。
clients() method in particular looks promising. 尤其是clients()方法看起来很有希望。 Keep in mind, that socket.io creates a unique room for each client.
请记住,socket.io为每个客户端创建一个唯一的空间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.