0

I'm running Hasura GraphQL on docker instance(window machine) exposed at

http://192.168.99.100:8080/v1/graphql

I want to perform subscription in my verticle but getting the following exception:

    com.apollographql.apollo.exception.ApolloNetworkException: Subscription failed
        at com.apollographql.apollo.internal.RealApolloSubscriptionCall$SubscriptionManagerCallback.onNetworkError(RealApolloSubscriptionCall.java:246)
        at com.apollographql.apollo.internal.subscription.RealSubscriptionManager$SubscriptionRecord.notifyOnNetworkError(RealSubscriptionManager.java:524)
        at com.apollographql.apollo.internal.subscription.RealSubscriptionManager.onTransportFailure(RealSubscriptionManager.java:296)
        at com.apollographql.apollo.internal.subscription.RealSubscriptionManager$SubscriptionTransportCallback$2.run(RealSubscriptionManager.java:556)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
        at java.net.SocketInputStream.read(SocketInputStream.java:170)
        at java.net.SocketInputStream.read(SocketInputStream.java:141)

Here's my sample code for apollo graphQL client:

public class MyFirstVerticle extends AbstractVerticle {

    @Override
    public void start(Future<Void> fut) {

        OkHttpClient okHttp = new OkHttpClient().newBuilder().build();

        ApolloClient subscribe = ApolloClient.builder()
                .serverUrl("http://192.168.99.100:8080/v1/graphql")
                .subscriptionTransportFactory(new WebSocketSubscriptionTransport.Factory(
                        "wss://192.168.99.100:8080/v1/graphql", okHttp))
                .build();

        subscribe.subscribe(new MySubscription(1)).execute(new ApolloSubscriptionCall.Callback<Optional<MySubscription.Data>>() {
    ..... 
....
oOXAam
  • 237
  • 1
  • 6
  • 20

1 Answers1

0

I found the solution, apparently it has to do with the type of connection you make. Im not an expert of this but, have you tried change wss to http?

:-)

user3154785
  • 121
  • 1
  • 6
  • No, I haven't tried changing wss to HTTP, bcz what I understood from docs was to make web socket connection with graphQL engine and for that wss protocol is used. – oOXAam Jul 16 '20 at 05:02