Late Disconnection
hrhosni opened this issue ยท 6 comments
Hello,
We're noticing that the "Connection Closed" event is happening 2 minutes after the "Transport Closed" event as you can see in the following screenshot:
Here's our disconnection code:
Channel channelInternal = ably.channels.get(channel);
try {
channelInternal.detach();
} catch (AblyException e) {
e.printStackTrace();
}
ably.connection.close();
Any idea what's happening here?
โค Automation for Jira commented:
The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3577
Hi @hrhosni, thanks for reporting this!
You're right, something isn't quite right here - the connection should be closed immediately by ably-java
.
What is happening in reality is that ably-java
is shutting down without properly closing the connection (it should send a message upstream to say the connection is closing), then after 2 minutes of no activity, the realtime service deems the connection to be abandoned and marks the connection as closed (which is normal behaviour). It does also mean that connections that have entered channel presence will remain in presence until this timeout occurs.
We've identified the reason why the connection isn't being closed cleanly (see this draft PR: #938), so will look at getting that fixed and released.
If you have any other questions, please reach out!
Thank you @AndyTWF
We've recently noticed that the number of open channels and connections is higher than it should be. For example, we connected 3 different devices on 3 different channels. The number of open channels and connections reported on the Dev Console was 3 for a while, but eventually it went up to 4 (and I am aware that the browser Dev Console itself counts as additional connections). We couldn't figure why the number of channels went up to 4.
Could this issue be related?
If not, any idea how this happens? How can we debug it?
Note that we've also just realized that we are using deprecated code to connect (because that's how it is in the official Ably documentation #640 )
That does sound odd! I've tried replicating this locally with a couple of ably-java
connections and haven't managed to do so. I always get the right number of channels consistently, though I do get +2 extra connections from the dev console being open.
With the original issue you described, channels might linger for a bit longer (due to connections taking a few minutes to close) - so it may possibly be related.
Were you able to spot the unexpected channel on the dev console anywhere? I'd expect it show which channels were active and in which regions.
Thanks for the extra info regarding the documentation - I'll get that looked into! ๐๐ป
The Ably documentation is being updated in ably/docs#1912 ๐