-
Notifications
You must be signed in to change notification settings - Fork 660
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
Websocket won't reopen on iOS #5697
Comments
Thanks for the detailed issue. I could reproduce. The problem lies here. When trying to open a WebSocket when offline, the code currently waits on a
I've been working on a revamp of that WebSocket code in the form of a new WebSocketNetworkTransport. It's currently incubating in the As a bonus, the new |
Thanks @martinbonnin. I was able to track the problem down to that line in the However, there's another optional protocol method in the I did notice that you've been doing new work on the |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Kotlin usage and allow us to serve you better. |
Version
3.8.2
Summary
When using websockets in a multiplatform project, the websocket will never reopen on iOS after a temporary network disconnect despite implementing the
.reopenWhen
block when initializing theWebSocketNetworkTransport
.After the websocket is closed due to a
NetworkError
, the logic in theWebSocketNetworkTransport
should evaluate the.reopenWhen
block and attempt to open the websocket again if the block returns true. If anotherNetworkError
is received after attempting to reopen the websocket, then.reopenWhen
is called again and the process should repeat itself until the websocket is successfully opened again or the.reopenWhen
block returns false.The actual behavior is that
.reopenWhen
is only called one single time and even if it returns true, the websocket is never reopened and.reopenWhen
is never called again. This means that any temporary network disruption causes the websocket to close permanently and any associated subscriptions get cancelled.Steps to reproduce the behavior
I opened an issue a few weeks ago to discuss this topic before I was sure if it was a bug or not. @martinbonnin was kind enough to create a very simple demo project during our discussion and that project reproduces the bug. Note that the bug only appears when you run on a real device and not on a simulator.
.reopenWhen
gets called one single time, but never again while the network is disconnected.reopenWhen
Logs
The text was updated successfully, but these errors were encountered: