Hello,
TL;DR
MAX_LAG_BEFORE_DISCONNECT needs to be set to a bigger value (at least 6000 + 2x MAX_LAG_BEFORE_PING)
RCA
For a few years Chromium browsers (Chrome, Edge & so on) have been using "Intensive Wake Up Throttling".
If a tab is inactive for 5 minutes, a request throttling is applied to that tab to limit request at a rate of "one request every 60s".
in netflux-client.js
// How much of a lag we accept before we will drop the socket
var MAX_LAG_BEFORE_DISCONNECT = 60000;
// [...]
ctx.pingInterval = setInterval(function () {
if (now() - ctx.timeOfLastPingReceived < MAX_LAG_BEFORE_PING) { return; }
if (now() - ctx.timeOfLastMsgReceived > MAX_LAG_BEFORE_DISCONNECT) {
closeWebsocket(ctx);
}
// [...]
}, PING_CYCLE);
Under throttling, the setTimeout won't be triggered exatly every 6000ms, it can vary ever so sligthly every time.
Considering MAX_LAG_BEFORE_DISCONNECT is also 60s, there are cases where now() - ctx.timeOfLastMsgReceived > MAX_LAG_BEFORE_DISCONNECT will be evaluated as 60001 > 60000, and thus closing the connection
Impact
The usage of this library lead to random socket disconnection. See XWIKI-23928 is subject to this problem. (Thanks to Martin who first found the issue).
Possible solution
See MR: #5
Hello,
TL;DR
MAX_LAG_BEFORE_DISCONNECT needs to be set to a bigger value (at least 6000 + 2x MAX_LAG_BEFORE_PING)
RCA
For a few years Chromium browsers (Chrome, Edge & so on) have been using "Intensive Wake Up Throttling".
If a tab is inactive for 5 minutes, a request throttling is applied to that tab to limit request at a rate of "one request every 60s".
in netflux-client.js
Under throttling, the setTimeout won't be triggered exatly every 6000ms, it can vary ever so sligthly every time.
Considering MAX_LAG_BEFORE_DISCONNECT is also 60s, there are cases where
now() - ctx.timeOfLastMsgReceived > MAX_LAG_BEFORE_DISCONNECTwill be evaluated as60001 > 60000, and thus closing the connectionImpact
The usage of this library lead to random socket disconnection. See XWIKI-23928 is subject to this problem. (Thanks to Martin who first found the issue).
Possible solution
See MR: #5