socket.io-stream icon indicating copy to clipboard operation
socket.io-stream copied to clipboard

Auto reconnect?

Open tiaod opened this issue 8 years ago • 3 comments

tiaod avatar Feb 03 '17 04:02 tiaod

Add these parameters in constructor options. eg:

var socket = require('socket.io-client')('http://localhost:8000', { reconnection: true, reconnectionDelay: 100, reconnectionAttempts: Infinity });

in this case I'm setting the reconnection to try every 100ms.

sidewaiise avatar Feb 04 '17 07:02 sidewaiise

And what I need to do is create a new stream after reconnect?

socket.on('connect', ()=>{
      var stream = ss.createStream()
      ss(socket).emit('dnode',stream)
      d.pipe(stream).pipe(d)
    })

tiaod avatar Feb 04 '17 08:02 tiaod

The settings you pass within the connect event should remain constant once reconnection occurs. Test the code with reconnect options and post your output (just use simple console logs on server and client to register events).

On 4 Feb. 2017, at 6:57 pm, tiaod [email protected] wrote:

And what I need to do is create a new stream after reconnect?

socket.on('connect', ()=>{ var stream = ss.createStream() ss(socket).emit('dnode',stream) d.pipe(stream).pipe(d) }) — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

sidewaiise avatar Feb 04 '17 15:02 sidewaiise