Socket.io specifying heartbeat

后端 未结 2 556
清酒与你
清酒与你 2020-12-30 05:11

I can\'t seem to find out how to set the heartbeat options for socket.io? I\'d love to be able to specify what happens when a \"timemout\" happens, and when the server hasn\

2条回答
  •  时光说笑
    2020-12-30 05:51

    For me the following worked:

    var app = express(); 
    var server = require('http').createServer(app); 
    var io = require('socket.io')(server); 
    
    io.set('heartbeat timeout', 4000); 
    io.set('heartbeat interval', 2000);
    

    For package dependency versions:

    "express": "^4.12.3",
    "socket.io": "1.0"
    

提交回复
热议问题