这是使用https://github.com/fent/socket.io-clusterhub为每个集群进程执行的:
var store = new (require('socket.io-clusterhub'));
var io = require('socket.io').listen(config.ports.socket);
io.configure(function(){
io.set('store',store);
});
console.log('Socket service listening on port '+config.ports.socket);
io.sockets.on('connection',function(socket){
if(typeof fn === 'function'){fn(socket);}
});
但看起来所有 4 个线程都在尝试使用不同的套接字 id 注册同一个用户:
debug: client authorized
info: handshake authorized XEGx6zAP7rSWGQcaxmUB
debug: client authorized
info: handshake authorized r0Vcr7Z-r_9MnylyxmUC
debug: client authorized
info: handshake authorized 7RWUgoCuZPIu0IyQxmUj
debug: client authorized
info: handshake authorized mq0zKCgeDkisr-rbxmUk
然后它完全断开连接:
debug: setting request GET /socket.io/1/websocket/XEGx6zAP7rSWGQcaxmUB
debug: set heartbeat interval for client XEGx6zAP7rSWGQcaxmUB
debug: websocket writing 7:::1+0
warn: client not handshaken client should reconnect
info: transport end (error)
debug: set close timeout for client XEGx6zAP7rSWGQcaxmUB
debug: cleared close timeout for client XEGx6zAP7rSWGQcaxmUB
debug: cleared heartbeat interval for client XEGx6zAP7rSWGQcaxmUB
debug: discarding transport
debug: setting request GET /socket.io/1/websocket/r0Vcr7Z-r_9MnylyxmUC
debug: set heartbeat interval for client r0Vcr7Z-r_9MnylyxmUC
debug: setting request GET /socket.io/1/websocket/7RWUgoCuZPIu0IyQxmUj
debug: set heartbeat interval for client 7RWUgoCuZPIu0IyQxmUj
debug: websocket writing 7:::1+0
warn: client not handshaken client should reconnect
info: transport end (error)
debug: set close timeout for client 7RWUgoCuZPIu0IyQxmUj
debug: cleared close timeout for client 7RWUgoCuZPIu0IyQxmUj
debug: cleared heartbeat interval for client 7RWUgoCuZPIu0IyQxmUj
debug: discarding transport
它根本无法运行回调例程,即使它继续像r0Vcr7Z-r_9MnylyxmUC
仍然处于活动状态一样:
debug: cleared heartbeat timeout for client r0Vcr7Z-r_9MnylyxmUC
debug: set heartbeat interval for client r0Vcr7Z-r_9MnylyxmUC
debug: emitting heartbeat for client r0Vcr7Z-r_9MnylyxmUC
debug: websocket writing 2::
debug: set heartbeat timeout for client r0Vcr7Z-r_9MnylyxmUC
debug: got heartbeat packet
debug: cleared heartbeat timeout for client r0Vcr7Z-r_9MnylyxmUC
debug: set heartbeat interval for client r0Vcr7Z-r_9MnylyxmUC
debug: emitting heartbeat for client r0Vcr7Z-r_9MnylyxmUC
debug: websocket writing 2::
debug: set heartbeat timeout for client r0Vcr7Z-r_9MnylyxmUC
debug: got heartbeat packet
debug: cleared heartbeat timeout for client r0Vcr7Z-r_9MnylyxmUC
debug: set heartbeat interval for client r0Vcr7Z-r_9MnylyxmUC
debug: emitting heartbeat for client r0Vcr7Z-r_9MnylyxmUC
debug: websocket writing 2::
debug: set heartbeat timeout for client r0Vcr7Z-r_9MnylyxmUC
debug: got heartbeat packet
debug: cleared heartbeat timeout for client r0Vcr7Z-r_9MnylyxmUC
debug: set heartbeat interval for client r0Vcr7Z-r_9MnylyxmUC
debug: emitting heartbeat for client r0Vcr7Z-r_9MnylyxmUC
有任何想法吗?谢谢!