Closed crishoj closed 1 day ago
As @jisotalo rightly noted:
we just need to make sure it's ok to do this "fire and forget" port unregistering
we just need to make sure it's ok to do this "fire and forget" port unregistering
Updated to resolve when AMS_TCP_PORT_CLOSE
packet is received.
Works well locally.
@jisotalo, could you check if this approach seems sane? In particular, the timeout you suggested is not included.
Also, in this PR, if the server doesn't end the TCP connection, it will stay open. So we would need to manually call
socket.end()
and/orsocket.destroy()
before resolving.
Testing the latest version of this PR locally, I was able to repeatedly connect and disconnect.
But I assume you're right — we should close the socket as well.
Do you think we need a timeout as well?
That looks great, just like I was thinking I would create it! I will look into it more carefully later.
We haven't had timeout before, but now when thinking it out loud, maybe there should be one?
It's not very likely to happen, but it could be possible that the port unregister is never confirmed by remote, which could cause the disconnect to never resolve. Maybe if there is no response (or socket close) in settings.timeoutDelay
, the client would call disconnectFromTarget(true)
to force closing (and then resolve). And also clear the amsTcpCallback
.
This of course increases complexity as we need to make sure to clear timers in all cases etc.
Timeout added.
Ensuring that both the timer and the callback are cleared in all cases does increase complexity.
Maybe if there is no response (or socket close) in settings.timeoutDelay, the client would call disconnectFromTarget(true) to force closing (and then resolve).
It seems disconnectFromTarget()
already handles failures from unregisterAdsPort()
by forcefully closing the connection.
Looking good! I'll check and merge as soon as I have time!
It seems
disconnectFromTarget()
already handles failures fromunregisterAdsPort()
by forcefully closing the connection.
You are right, it's already there!
Checked out and tests with tc2&tc3 run ok. And if in your tests the AdsRouterConsole works as well, I think wer are done here :)
Thanks for checking!
Possible fix for #157.
Also,
this.socketWrite()
is not asynchronous, soawait
doesn't have any effect.