-
Notifications
You must be signed in to change notification settings - Fork 6
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
fix: websocket not receiving messages after some time #791
fix: websocket not receiving messages after some time #791
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #791 +/- ##
=============================================
- Coverage 58.44% 58.29% -0.15%
Complexity 666 666
=============================================
Files 431 432 +1
Lines 11138 11170 +32
Branches 1122 1122
=============================================
+ Hits 6510 6512 +2
- Misses 4150 4180 +30
Partials 478 478 |
Labeler is currently broken: srvaroa/labeler#43. Seems to be caused by: niemeyer/gopkg#63 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bravo! Nice catch 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
* fix: websocket not receiving messages after some time * chore: reduce ping interval to 20s Co-authored-by: Mohamad Jaara <mohamad.jaara@wire.com>
PR Submission Checklist for internal contributors
The PR Title
The PR Description
What's new in this PR?
Issues
After some time, the websocket dies. It completely stops receiving messages without any sings of errors, exceptions, or anything else being called.
Causes
As we do not send messages to the backend, it seems that the backend expects at least some pings every so often to keep the connection alive.
After some time without receiving anything, the backend just leaves the connection in a limbo and doesn't send any more messages through it.
Solutions
Add a ping every so many seconds.
It seems that @makingthematrix also went through this problem back in 2019 for the Scala app (see this commit), and 30s has been the magic number that carried the Scala app until now.
Unfortunately OkHttp doesn't handle dynamic pinging, so it must be configured directly into the HttpEngine, and it seems that the configuration in WebSockets is just ignored if you're using OkHttp.
So, even though adding it to OkHttp fixes it for Android and JVM, I've added it to Ktor as well so it also works for other platforms.
Testing
Manually tested as we can't yet mock WebSockets using Ktor.
PR Post Merge Checklist for internal contributors
References
feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764
.