I sucessfully managed to use ApolloClient in order to deal with GraphQL Subscription over websocket. I can see events onNext happening. Unfortunatly when my server is facing difficulties, ApolloClient is not able to reconnect using the same websocket.
`
private ApolloSubscriptionCall<Subscription.Data> getMySubscriptionCall() {
Subscription = Subscription.builder().build();
return apolloClient.subscribe(Subscription);
}
/* */
okHttpClient = new OkHttpClient.Builder()
.addInterceptor(new LoggingInterceptor())
.pingInterval(30, TimeUnit.SECONDS)
.retryOnConnectionFailure(true)
.build();
apolloClient = ApolloClient.builder()
.serverUrl(env.getBaseUrl())
.okHttpClient(okHttpClient)
.subscriptionTransportFactory(new WebSocketSubscriptionTransport.Factory(env.getSubscriptionBaseUrl(), okHttpClient))
.build();
disposables.add(Rx2Apollo.from(getMySubscriptionCall())
.subscribeOn(Schedulers.io())
.subscribeWith(new Subscriber()));
`
Is there any other particular configuration that i must add in order to reconnect the client ?
Thx for advices
Have you tried to unsubscribe and then subscribe after some delay like 10-20 seconds? After 10 sec timeout we will kill web socket connection.
Actually I guess we need to add support of heart beat from server side:
https://github.com/apollographql/subscriptions-transport-ws/blob/7482425bb27139d99f45c88ac46c7223c210fbf9/src/message-types.ts#L7
Most helpful comment
Actually I guess we need to add support of heart beat from server side:
https://github.com/apollographql/subscriptions-transport-ws/blob/7482425bb27139d99f45c88ac46c7223c210fbf9/src/message-types.ts#L7