在用socket.io做web聊天系统的时候为了解决nodejs的单线程易崩溃的状况,使用cluster.fork()多开了些线程,有此带来的问题是每一个线程都有自己的socket,多个浏览器测试发现有的时候能进入同一个进程就可以通信,没有进入的话后台狂打印信息 debug - cleared heartbeat interval for client xDbxAhAOkoQHfQWC7TGT debug - discarding transport debug - client authorized info - handshake authorized wGNiKiQxge2j1tpQ7TGV debug - client authorized info - handshake authorized A50oRdQZNg27S2Hr7TGW debug - setting request GET /socket.io/1/websocket/wGNiKiQxge2j1tpQ7TGV debug - set heartbeat interval for client wGNiKiQxge2j1tpQ7TGV debug - websocket writing 7:::1+0 warn - client not handshaken client should reconnect info - transport end (error) debug - set close timeout for client wGNiKiQxge2j1tpQ7TGV debug - cleared close timeout for client wGNiKiQxge2j1tpQ7TGV debug - cleared heartbeat interval for client wGNiKiQxge2j1tpQ7TGV debug - discarding transport debug - client authorized info - handshake authorized BmULkJ6v4etxDReY7TGX debug - setting request GET /socket.io/1/websocket/BmULkJ6v4etxDReY7TGX debug - set heartbeat interval for client BmULkJ6v4etxDReY7TGX debug - websocket writing 7:::1+0 warn - client not handshaken client should reconnect info - transport end (error) 一直不停打印,想知道是为什么?以及解决问题的思路? 有一个想法是把socket只写到主线程里,就是写到一个线程里,其他线程不管,看这样想是否正确呢?
作者