等待数据时 gRPC UNAVAILABLE EOF 错误

gRPC UNAVAILABLE EOF Error while waiting for data

我正在尝试创建一个 Java 版本的 jtimon Github

On Github可以看到定义服务的proto消息

我的 Java 代码如下所示

package jti.collector;

public class JTICollector {

    private static final Logger log = LoggerFactory.getLogger(JTICollector.class);

    private static final String DEVICE_ADDRESS = "100.96.244.41";
    private static final int GRPC_PORT = 50051;

    private static final int SAMPLE_FRQ = 2000;
    private static final long SLEEP_TIME = 10000;

    private static final long SLEEP_TIME_FOR_REQ = 10;

    public static void main(final String[] args) {


        final String username = "AAA";
        final String password = "BBB";

        log.info("UserName : " + username);

        final ManagedChannel channel = ManagedChannelBuilder
                .forAddress(DEVICE_ADDRESS, GRPC_PORT)
                .usePlaintext(true)
                .build();

        LoginGrpc.LoginBlockingStub loginStub = LoginGrpc.newBlockingStub(channel);

        Authentication.LoginRequest loginRequest = Authentication.LoginRequest.newBuilder()
                .setClientId("foo-bar")
                .setUserName(username)
                .setPassword(password)
                .build();

        Authentication.LoginReply loginReply = loginStub.withDeadlineAfter(SLEEP_TIME_FOR_REQ, TimeUnit.SECONDS)
                .loginCheck(loginRequest);

        log.info("LoginReply : " + loginReply.toString());

        OpenConfigTelemetryGrpc.OpenConfigTelemetryStub stub = OpenConfigTelemetryGrpc.newStub(channel);

        Telemetry.SubscriptionRequest request = Telemetry.SubscriptionRequest.newBuilder()
                .addPathList(Telemetry.Path.newBuilder()
                        .setPath("/interfaces")
                        .setSampleFrequency(SAMPLE_FRQ) //In mills
                        .build())
                .build();

        final CountDownLatch finishLatch = new CountDownLatch(1);

        StreamObserver<Telemetry.OpenConfigData> responseObserver = new StreamObserver<Telemetry.OpenConfigData>() {
            @Override
            public void onNext(final Telemetry.OpenConfigData value) {
                log.info("Received Value : " + value.toString());
            }

            @Override
            public void onError(final Throwable t) {
                log.warn("onError", t);
                finishLatch.countDown();
            }

            @Override
            public void onCompleted() {
                log.info("onCompleted");
                finishLatch.countDown();
            }
        };

        stub.telemetrySubscribe(request, responseObserver);

        log.info("Blocking on latch");
        try {
            finishLatch.await();
        } catch (InterruptedException e) {
            log.warn("Finnish Latch Failed", e);
        }

    }

}

登录成功。但是 onNext() 永远不会被调用。并且 onError() 触发了一条消息,其中包括 我正在寻找的一些内容

io.grpc.StatusRuntimeException: UNAVAILABLE: {"created":"@1511903558.423607783","description":"EOF","file":"../../../../../../../../src/dist/grpc/src/core/lib/iomgr/tcp_posix.c","file_line":235,"grpc_status":14}i-safi-nameRIPV4_UNICAST:B
>afi-safis/afi-safi[afi-safi-name='IPV4_UNICAST']/state/enabledH:A
=afi-safis/afi-safi[afi-safi-name='IPV4_UNICAST']/state/activeH
    at io.grpc.Status.asRuntimeException(Status.java:526)
    at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:418)
    at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:41)
    at io.grpc.internal.CensusStatsModule$StatsClientInterceptor.onClose(CensusStatsModule.java:663)
    at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:41)
    at io.grpc.internal.CensusTracingModule$TracingClientInterceptor.onClose(CensusTracingModule.java:392)
    at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:443)
    at io.grpc.internal.ClientCallImpl.access0(ClientCallImpl.java:63)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:525)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access0(ClientCallImpl.java:446)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImplStreamClosed.runInContext(ClientCallImpl.java:557)
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

查看此处了解更多信息https://github.com/grpc/grpc-java/issues/3800

总而言之,问题是; grpc 服务器无法解析请求中的 tracing 相关 header。但是客户端没有public界面可以关闭