-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Option for reconnect Back-Off (to prevent continual reconnection attempts when connection closed by remote host) #589
Comments
I'm not sure that there is a solution to this unfortunately; as per the spec:
So most 'well behaved' brokers will complete the handshake and throw the message away. While disconnecting is given as an option the client has no way to determine why the broker dropped the connection and, as such, cannot remove the offending message from it's store (the spec does not make any provision for 'rejected' messages). The same applies in other situations (e.g. another client connects with the same client ID); the broker just drops the connection and we have no way to differentiate that from a network issue. The above means that I don't think we really have any option other than to attempt to reconnect immediately and send through any queued messages. If you can suggest an alternative I'll definitely consider it (but most libraries use the same approach). |
Sorry for not being clear, but the only issue I'm pointing at is the reconnect frequency performed when a close event occurs. (The examples were just meant as a situation where this occurs) When a remote host closes a connection in this manner, I'm seeing upwards of 50-100 connect/disconnect events per second, and am concerned about this behavior (particularly on constrained networks) In my case, I was able to use the Reconnect handler to add a delay after receiving an an io.EOF event. |
No worries - I have amended the title so that it more clearly covers what I believe you are requesting. The initial reconnection attempt needs to be immediate (because the issue may be a momentary network glitch) but I agree that continually attempting to reconnect is counter productive. Some form of Back-Off algorithm (reset after the connection has been up for more than a user specified time) would be beneficial. |
…ackoff related to eclipse-paho#589 Signed-off-by: Daichi Tomaru <[email protected]>
…n lost is detected immediately after connecting. eclipse-paho#589 Signed-off-by: Daichi Tomaru <[email protected]>
Summary of this issue (I think)There seem to be at least 3 points should have appropriate sleep with back-off algorithm.
In this GitHub issue, the following are nowly reported for each points.
Cause of No.3
|
… lost is detected immediately after connecting. eclipse-paho#589 Signed-off-by: Daichi Tomaru <[email protected]>
…reconnect loops Add back-off controller for sleep time of reconnection when connection lost is detected immediately after connecting. #589 This issue could be caused by an invalid publish request (which leads to the broker dropping the connection immediately).
Due to the way connect/reconnects are handled, no delay is used when a remote host closes a connection.
The simplest example is publishing using a bad topic with QoS > 0
The client will store the bad message, and get stuck in a cycle of connect, publish, connection closed, reconnect, ...
Similar behavior has been noted when:
Connection is dropped due to duplicate clientids in a broker
Performing an operation (subscribe/publish) on an AWS data broker when your device lacks the policy settings, or has had policy permissions revoked.
The text was updated successfully, but these errors were encountered: