Controlling the heartbeat timeout from the client in socket.io

前端 未结 3 1584
天涯浪人
天涯浪人 2020-12-02 13:41

I have mobile clients connected to a node.js server, running socket.io via xhr-polling. I have two type of clients:

  • Type A

    When the connection break

3条回答
  •  甜味超标
    2020-12-02 14:18

    In socket.io 1.x, the API has changed but the concept remains the same.

    Instead of heartbeatInterval and heartbeatTimeout, the properties are pingInterval and pingTimeout. For example,

    var server = app.listen(80);
    io = socketio(server,{'pingInterval': 45000});
    

    See the documentation at http://socket.io/docs/server-api/#server(opts:object), which will direct you to https://github.com/Automattic/engine.io#methods-1.

提交回复
热议问题