0

我在暴露的 docker 实例(窗口机器)上运行 Hasura GraphQL

http://192.168.99.100:8080/v1/graphql

我想在我的 Verticle 中执行订阅,但出现以下异常:

    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)

这是我的 apollo graphQL 客户端示例代码:

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>>() {
    ..... 
....
4

1 回答 1

0

我找到了解决方案,显然它与您建立的连接类型有关。我不是这方面的专家,但是,您是否尝试过将wss更改为http

:-)

于 2020-07-15T23:16:29.360 回答