apollo-kotlin icon indicating copy to clipboard operation
apollo-kotlin copied to clipboard

Open/Close web socket connection

Open gayathri-nair03 opened this issue 5 years ago • 4 comments

Im using Apollo Android Client v1.0.0 I see that you have exposed enableSubscriptions() and disableSubscriptions(). These internally open/close the web socket connection. Have you exposed any other methods (in v1.0.0) that let us open/close the web socket connection without having to worry about creating a subscription? Also, are there any such methods available in the latest version of Apollo Client (v2.3.1) ?

gayathri-nair03 avatar Sep 28 '20 13:09 gayathri-nair03

Hi 👋 , Can you detail a bit more what you mean by "open/close the web socket connection without having to worry about creating a subscription" ? Why would you need other methods than enableSubscriptions()/disableSubscriptions() ?

martinbonnin avatar Sep 28 '20 13:09 martinbonnin

I need to open the web socket connection open on app init, not on first subscription. This is so that we can avoid the sudden spike/surge in connection requests, say when millions of users land on a certain screen altogether (worst case scenario). So we want to make web socket connection on app init itself and then subscribe later on.

gayathri-nair03 avatar Sep 28 '20 16:09 gayathri-nair03

Thanks for the explanation! I'm not aware of anything like this but I'm not super familiar with subscription code so don't take this as gospel. I'll keep looking.

martinbonnin avatar Sep 28 '20 16:09 martinbonnin

Typically you would want to keep the transport separate from graphql. Web socket Connection lifecycle should be managed by the dev.

tusharmath avatar Sep 29 '20 15:09 tusharmath