When the node server disconnects the client using socket.disconnect(true); I manually open the connection again on the client side using socket.open().
The problem is that when the socket.open() is triggered, the socket.on('reconnect', (attemptNumber) => { function isn't.
socket.on('connect', () => { works fine, but I'd like the code inside to only execute on a reconnect after the server has closed on the connection.
Why doesn't the reconnect function work on a manual reconnect and is there something I can do to fix or work around this problem?
reconnectevent and it's associatedattemptNumberonly happen if the socket is attempting an automatic reconnect (because it lost it's connection from various unexpected things like the server was restarted, loss of network connectivity, etc..). When the server forcibly disconnects the socket, the socket knows exactly why it disconnected and does not try to reconnect. Sosocket.open()is always a connection not a re-connection. - gforce301