-
Notifications
You must be signed in to change notification settings - Fork 657
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
Subscription switched to DISCONNECTED #2765
Comments
Hi! Thanks for the detailed report. Maybe the authorisation token is expired? Is your GraphQL playground public so I could take a look by any chance? To answer your questions:
I guess something closed the websocket, most likely on the server but it might be on the client too.
Can you intercept the Websocket traffic with Charles Proxy? That should give you a good idea of who's closing the connection and if there are any unusual messages being transfered.
A workaround would be to use If it's authorisation related, you can also take a look at apolloClient.subscriptionManager.reconnect() for how to update the authorization parameters |
Hi Martin , First of all many thanks for your quick reply. Unfortunately the playGround is not public but i can ensure that if i open a subscription from playground and on same time in playground it is not disconnected at all and always Regarding the the token expiration it is not expired because i tried to do pull to refresh after it is Regarding your answer if have the following questions 1] is there is a way to Log exception when it is disconnected to find what it the issue ? 2] should i use flow.retry OR apolloClient.subscriptionManager.reconnect() if this case happened ? 3] using I am just trying to overcome this issue because i want to go production and afraid to have this |
Hi! II think using
There might also be something to investigate around the heartbeat but without a way to reproduce it's going to be difficult. It might be similar to this bug https://github.com/apollographql/apollo-android/issues/2733 that I wanted to investigate. I'll post some progress there if I find anything. |
Great i will be waiting your investigation results 👍 |
Sounds good. Just a heads up that it might take some time since I'm not super familiar with the subscription code. Also that other issue I linked is maybe completely different so if you need a short term solution, I'd recommend the |
@martinbonnin i totally understand take your time 👍 I just want to inform you that So i can use
i would like in case of disconnection try at least to connect again , how i can pass the SubscriptionConnectionParams to Also one more question : |
I think i have faced with similar problem
The problem lives here here So on any error channel will be closed, and you will never recieves notifications on client. You have to handle errors in subscription inside flow Apollo docs You should use |
Did you solved it? |
My temporary solution here. Rewrite |
Any update on this, I am also facing same problem. |
i am also facing this issue on https server URL but on ip it works fine. Subscription disconnects after 1 min on https url but not on IP, not sure if it might be the issue with nginx. |
Anyone still around with this issue? It's been a while but ApolloClient.Builder()
.serverUrl(sampleServer.graphqlUrl())
.retryOnError { it.operation is Subscription }
.subscriptionNetworkTransport(
WebSocketNetworkTransport.Builder()
.serverUrl(sampleServer.subscriptionsUrl())
.build()
)
.build() If anyone's get a chance to try it, I'm eager to know what you think. If not, and since this issue is almost 3 years old now, I'll close it and anyone reading this should feel free to open a new one. |
Closing. See #5862 for follow ups. |
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. |
Summary
After subscription is opened with 1 min or so it switched to Disconnected
Background
I added one subscription into my project to listen for new events coming from graphQL server
I found out that sometimes events is not received in the app however . if i am listening to subscriptions from GraphQl Playground i am able to see the events there !!
How i was sure that this is a bug
I started to log the state for the subscription using the following listener
apolloClient.subscriptionManager.addOnStateChangeListener { fromState, toState -> }
What i found is the following states are triggered :
DISCONNECTED -> CONNECTING -> CONNECTED -> ACTIVE
and i actually receive events but
After 1 min or 2 mins it is directly changed to
DISCONNECTED
without going toStopping
orStopped
and in this state i don't receive any events
Version
2.4.4
MyCode
[1] setup
[2]
suspend fun subscribeToNewsEvents() = apolloClient.subscribe(NewsEventsSubscription()).toFlow() .map { it.data!!.NewsEvents!! }
[3] i am collecting this flow in the activity
My Question
[1] why it is disconnected after being Active ?
[2] how i can know the cause of this issue or log it ?
[3] how to overcome this because this a really blocking issue preventing us from releasing our app ?
Please let me know if i am not clear for the bug
The text was updated successfully, but these errors were encountered: