Socket.io “connection” event fired on every client heartbeat?

后端 未结 2 2203
陌清茗
陌清茗 2021-01-07 02:11

I have a basic Socket.io server setup like this:

var server = express.createServer().listen(port);
    this.io = socketIO.listen(server);

this.io.sockets.on         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-07 03:03

    Are you setting too low a value for closetimeout and heartbeat interval. The default values for these are 60 sec and 25 sec. Typical network lag is of the order of 5 sec. So with the values that you have set, the client does not respond in the time specified, so the connection is closed. When the client connects again, the connection event is fired.

提交回复
热议问题