MQTT.js
MQTT.js copied to clipboard
Change reconnect logic to exponential backoff with random delay
If a client loses the connection, the reconnect starts immediately. If your broker died and you restart it, all clients try to connect at the same time and may cause problems with traffic, or authorization logic and maybe kill it again. So in my opinion the reconnect should be changed to an exponential backoff with jitter, explained in this article.
What do you think about this idea?
Would you mind to send a PR? I think we should also cap the max timeout.
Okay, I'll dig into the code and prepare something.
Has been finished? It's a good job @sclausen
Yes, that's what I've got so far. Any thoughts about the code?
I thought mcollina is right; You shoud define a strategy with object;
With this object, you can define retry_strategy with params such as delay_time
, max_attempts
, delay_random_range
etc...
It's would be a strategy which support random delay
or the other custom-supported-strategy
;
And also you can define actions of the object(like mcollina said); It would be helpful to control the reconnection process;
Err.. btw, it would be a lot of works
Has this issue been resolved yet?
@shivamydv No, this issue is still marked as open
.
This is an automated message to let you know that this issue has gone 365 days without any activity. In order to ensure that we work on issues that still matter, this issue will be closed in 14 days.
If this issue is still important, you can simply comment with a "bump" to keep it open.
Thank you for your contribution.
This issue was automatically closed due to inactivity.