Wednesday 31 May 2017

Node reconnection issues

In my web app I'm using socket.disconnect() and then reconnecting later in the program. A simplified version of what I'm doing is this:var socket = io.connect('localhost:3299') // code socket.disconnect() while (condition) { socket.socket.reconnect() // the two sockets is intentional // more code socket.disconnect() } My issue is that when the socket reconnects, it sends duplicate updates - so when the loop has run 1 time the socket sends 1 message when I use socket.emit(), 2 times it sends 2 messages, etc etc. Anyone know what's going on here?

Submitted May 31, 2017 at 03:26PM by J354

No comments:

Post a Comment