Hi, I know it's been a while since this change has been introduced, but I was wondering if you could still remember the rationale behind it as it doesn't look right.
Scenario:
My websocket gets disconnected (e.g. by the remote) and start automatically reconnecting.
Due to various reasons I also have another reconnect mechanism in my app where I do socket.close() followed by socket.open().
When remote finally comes back, both mechanisms connect and I end up with two connections.
The reasons why both connect is because when socket.close() is called, the automatic reconnect mechanism doesn't stop (which doesn't seem right even in general case - I'm calling close explicitly so I want it to stop). This has been introduced since this PR quite a while back in particular the close() method change:
// It seems to me that timer.shutdown() should be unconditional here
if (options.reconnectInSeconds() <= 0 && !options.reconnect() ) {
timer.shutdown();
}
Unfortunately I could not find a workaround for this issue so far. My close/open mechanism needs to kick in even if connection is in Open state (so I can't stop it if automatic reconnect succeeds first), but also when close/open mechanism succeeds first I can't stop automatic reconnect. Close also doesn't take any options that would make it stop reconnects.
I'd be happy to make the change, but since I don't understand the reasoning behind the condition I first want to understand if it can be removed or another approach is needed (e.g. add method to Socket to stop reconnects).
CC original author for visibility @ricardojlrufino
Hi, I know it's been a while since this change has been introduced, but I was wondering if you could still remember the rationale behind it as it doesn't look right.
Scenario:
socket.close()
followed bysocket.open()
.The reasons why both connect is because when
socket.close()
is called, the automatic reconnect mechanism doesn't stop (which doesn't seem right even in general case - I'm calling close explicitly so I want it to stop). This has been introduced since this PR quite a while back in particular theclose()
method change:Unfortunately I could not find a workaround for this issue so far. My close/open mechanism needs to kick in even if connection is in Open state (so I can't stop it if automatic reconnect succeeds first), but also when close/open mechanism succeeds first I can't stop automatic reconnect. Close also doesn't take any options that would make it stop reconnects.
I'd be happy to make the change, but since I don't understand the reasoning behind the condition I first want to understand if it can be removed or another approach is needed (e.g. add method to Socket to stop reconnects).
CC original author for visibility @ricardojlrufino