Closed Frotty closed 4 years ago
That jitter value should be much larger.. probably in the range of 1-5 seconds even. Then it should also have a max timeout length so the timeout doesn't get insanely huge. Something like max of 5 minutes sounds reasonable IMO.
@prawnsalad Agreed on the jitter. For the maximum I would prefer a higher one, since my actual use case was getting g-lined from quakenet, which takes about an hour to clear up.
Looks good, will need to give it some testing.
@prawnsalad Anything left to do here?
After trying this out the reconnect timeouts (reconnect_attempts++
between each call) gives:
13657
14954
19766
37475
68025
135704
260587
That's a bit high and clustered at the beginning so I tweaked it to:
function calculateExponentialBackoff() {
const jitter = 1000 + Math.floor(Math.random() * 5000);
const attempts = Math.min(reconnect_attempts, 30);
const time = 1000 * Math.pow(2, attempts);
return Math.min(time, auto_reconnect_max_wait) + jitter;
}
Which gives a better result:
3077
7235
8395
11505
21760
36047
65086
This has also removed the redundant auto_reconnect_wait
option.
@Frotty are you able to rebase/squash this and apply the tweak above?
Nice, will get to testing it tonight/tomorrow ++
See https://github.com/kiwiirc/irc-framework/issues/140