简体   繁体   中英

Socket.io on multiple servers with HaProxy

I have HAProxy which serve multiple servers with nodejs on expressjs. I have added to that express socket.io and to make them work i tried to connect them with socket.io-redis and socket.io-ioredis . All looks to be connected without any error but when an user get his socket connected with different server from other user, their emits don't read don't send to other servers. Nodejs setup

var app = express();
var server = require('http').Server(app);
var io = require('socket.io').listen(server);
var redis = require('socket.io-ioredis');
io.adapter(redis({ host: 'serverIP', port: 6565 }));
server.listen(6565);

How do i do the emit: io.to(roomID).emit(event, object);

实际的问题是服务器上连接Redis的端口已被防火墙阻止。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM