How configure reconnecting in socket.io?

前端 未结 4 1792
孤独总比滥情好
孤独总比滥情好 2021-02-02 08:40

I create socket.io connection with next code

var socket = new io.connect(\'http://localhost:8181\', {
    \'reconnect\': true,
    \'reconnection delay\': 500,
          


        
4条回答
  •  太阳男子
    2021-02-02 09:18

    This is an old question, but for other people like me, who are looking how to configure reconnect in socket.io (1.x) here is a correct syntax:

    var socket = new io.connect('http://localhost:8181', {
        'reconnection': true,
        'reconnectionDelay': 1000,
        'reconnectionDelayMax' : 5000,
        'reconnectionAttempts': 5
    });
    

提交回复
热议问题