-
Notifications
You must be signed in to change notification settings - Fork 55
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
Connection recovery not working #1844
Comments
@michalzaq12 reconnection works in following manner
|
@michalzaq12 Can you check confirm if connection recovery works after 15 seconds ? |
I know exactly how it works. It doesn't change the fact that there's some bug in the implementation (regression from v1).
After 15 seconds, the SDK tries to reconnect but fails every time. |
Is there any template for minimal reproducible repo? |
@michalzaq12 there's no template as such. It will be great if you can either post code here or best if create a separate repository with steps to reproduce the bug. That way, we can reproduce it given environment i.e. nodejs, browser etc |
Environment: Windows 11, Chrome 127 Reproduction code (ably-js 2.3.1): var client = new Ably.Realtime({
key: '<ABLY_KEY>',
transports: ['web_socket']
});
setInterval(() => {
console.info('STATE: ' + client.connection.state)
}, 5000) Reproduction steps:
|
Hi @michalzaq12 ! Thank you for spotting the issue and providing detailed explanations and steps to reproduce it. As a side note, is there something unusual about your network setup? For example, do you have a VPN program installed that might be keeping the request to |
Default network settings. I don't use a VPN. |
Some of our users have encountered this reconnection issue after waking up PC. It seems that the problem is that the internet does not become available immediately after PC connecting to Wi-Fi or LAN. I was able to reproduce this on macOS. To do so, I installed the Network Link Conditioner from Apple (https://developer.apple.com/download/more/?q=Additional%20Tools), which is part of the Additional Tools for Xcode package. Steps: As mentioned earlier, if the startWebSocketSlowTimer ably-js/src/common/lib/util/defaults.ts Line 86 in bd66293
Workaroundvar client = new Ably.Realtime({
...
});
client.options.timeouts.webSocketSlowTimeout = 0; // <--- workaround |
@VeskeR When will the bug be fixed? |
Hi @michalzaq12 , fixing this will be our priority next week and I'm going to work on it on Monday and hopefully release a fix early next week. |
Hello @VeskeR , same issue on the React Native, I'm not sure this workaround would work here. The problem happens when the internet connection is not quite good (especially on bad public wifi), and the app goes into an infinite loop of Disconnected -> Reconnecting -> Disconnected. |
I was able to fix the issue locally and right now adding some additional tests for the future. We aim to review the PR and release a patch version on npm today. |
…ycle Fixes a regression introduced in ably-js v2 in the "no upgrade" PR [1]. Under certain network conditions (internet down) a race condition could occur in the connection manager. Specifically, websocket connectivity check in the `startWebSocketSlowTimer` function needed to set the `wsCheckResult` flag to `false` before the timer was cleared by other code branches. If that happened, it then caused an endless loop of websocket connection retries, even after the network conditions stabilized. A websocket transport would successfully open but then be immediately disposed due to the `wsCheckResult` flag still being set to `false`, without any mechanism to reset it in this scenario. Upon closer look, it makes sense that the websocket connection health flags (`wsCheckResult` and `abandonedWebSocket`) should be reset when attempting a new websocket connection. The previous solution did not explicitly reset these flags in the `connectWs` function, leading to the described race condition and endless loop. Thus, `wsCheckResult` and `abandonedWebSocket` are now reset to their neutral values upon entering the `connectWs` function. Resolves #1844 [1] #1645
Websocket reconnection issue has been fixed in ably-js 2.3.2 release. @Gid733 The problem should be fixed on all platforms. Please update to ably-js 2.3.2 version and see if that fixes it in your case. If you're still experiencing reconnection issues with 2.3.2 release, please let us know. |
Ably ver: 2.3.1
Description
Realtime connection (websocket, only websocket transport provided) is not restored after network connection is lost. SDK tries to connect without success (network is already available).
My observation
checkWsConnectivity()
is called, which of course fails (that's fine).checkWsConnectivity()
can by called only once (WHY?) , sowsCheckResult
is alwaysfalse
ably-js/src/common/lib/transport/connectionmanager.ts
Line 1104 in 8ba8ec2
tryTransportWithFallbacks()
is called when trying to reconnectshouldContinue()
intryTransportWithFallbacks()
body always returnsfalse
, which calltransport.dispose()
┆Issue is synchronized with this Jira Task by Unito
The text was updated successfully, but these errors were encountered: