Streaming grpc:取消:在收到半结算前取消

Streaming grpc:取消:在收到半结算前取消,streaming,grpc,grpc-java,Streaming,Grpc,Grpc Java,我正在做从客户端到服务器的流式传输。我在服务器上多次收到此错误: CANCELLED: cancelled before receiving half close io.grpc.StatusRuntimeException: CANCELLED: cancelled before receiving half close at io.grpc.Status.asRuntimeException(Status.java:517) ~[grpc-core-1.12.0.jar:1.12.0

我正在做从客户端到服务器的流式传输。我在服务器上多次收到此错误:

CANCELLED: cancelled before receiving half close
io.grpc.StatusRuntimeException: CANCELLED: cancelled before receiving half close
    at io.grpc.Status.asRuntimeException(Status.java:517) ~[grpc-core-1.12.0.jar:1.12.0]
    at io.grpc.stub.ServerCalls$StreamingServerCallHandler$StreamingServerCallListener.onCancel(ServerCalls.java:272) ~[grpc-stub-1.12.0.jar:1.12.0]
    at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.closed(ServerCallImpl.java:293) [grpc-core-1.12.0.jar:1.12.0]
    at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1Closed.runInContext(ServerImpl.java:737) [grpc-core-1.12.0.jar:1.12.0]
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) [grpc-core-1.12.0.jar:1.12.0]
    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) [grpc-core-1.12.0.jar:1.12.0]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_171]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_171]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
Jul 20 2018 04:56:28.441 PM [grpc-default-worker-ELG-3-2] DEBUG io.grpc.netty.NettyServerHandler:86 - [id: 0xae106a63, L:/127.0.0.1:9090 - R:/127.0.0.1:40808] OUTBOUND RST_STREAM: streamId=7 errorCode=5
Jul 20 2018 04:56:28.451 PM [grpc-default-worker-ELG-3-2] DEBUG io.grpc.netty.NettyServerHandler:86 - [id: 0xae106a63, L:/127.0.0.1:9090 - R:/127.0.0.1:40808] INBOUND DATA: streamId=7 padding=0 endStream=false length=52 bytes=000000002f3a2d0801180120b96028aa1230c3c8013a055452414345420254344a0968656164646c696e655207766973686e7573
Jul 20 2018 04:56:28.453 PM [grpc-default-worker-ELG-3-2] DEBUG io.grpc.netty.NettyServerHandler:86 - [id: 0xae106a63, L:/127.0.0.1:9090 - R:/127.0.0.1:40808] OUTBOUND RST_STREAM: streamId=7 errorCode=5
Jul 20 2018 04:56:28.770 PM [grpc-default-worker-ELG-3-2] DEBUG io.grpc.netty.NettyServerHandler:86 - [id: 0xae106a63, L:/127.0.0.1:9090 - R:/127.0.0.1:40808] OUTBOUND GO_AWAY: lastStreamId=7 errorCode=2 length=24 bytes=436f6e6e656374696f6e2072657365742062792070656572
Jul 20 2018 04:56:28.773 PM [grpc-default-worker-ELG-3-2] DEBUG i.netty.handler.codec.http2.Http2ConnectionHandler:86 - [id: 0xae106a63, L:/127.0.0.1:9090 ! R:/127.0.0.1:40808] Sending GOAWAY failed: lastStreamId '7', errorCode '2', debugData 'Connection reset by peer'. Forcing shutdown of the connection.
java.io.IOException: Broken pipe
    at sun.nio.ch.FileDispatcherImpl.writev0(Native Method) ~[na:1.8.0_171]
    at sun.nio.ch.SocketDispatcher.writev(SocketDispatcher.java:51) ~[na:1.8.0_171]
    at sun.nio.ch.IOUtil.write(IOUtil.java:148) ~[na:1.8.0_171]
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:504) ~[na:1.8.0_171]
    at io.netty.channel.socket.nio.NioSocketChannel.doWrite(NioSocketChannel.java:418) ~[netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:934) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:360) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:901) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1376) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.handler.codec.http2.Http2ConnectionHandler.onError(Http2ConnectionHandler.java:619) [netty-codec-http2-4.1.22.Final.jar:4.1.22.Final]
    at io.grpc.netty.AbstractNettyHandler.exceptionCaught(AbstractNettyHandler.java:81) [grpc-netty-1.12.0.jar:1.12.0]
    at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:285) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:264) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:256) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.DefaultChannelPipeline$HeadContext.exceptionCaught(DefaultChannelPipeline.java:1381) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:285) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:264) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.DefaultChannelPipeline.fireExceptionCaught(DefaultChannelPipeline.java:933) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.handleReadException(AbstractNioByteChannel.java:112) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:157) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459) [netty-transport-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886) [netty-common-4.1.22.Final.jar:4.1.22.Final]
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.22.Final.jar:4.1.22.Final]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]

我可以知道为什么吗?我不会关闭grpc。发生此错误后,GRPC不会关闭。错误也不是一直发生的

看起来客户端挂断了服务器,或者网络中的路由器终止了连接。你在什么网络环境中测试这个?它在本地。客户端和服务器。客户端仍然可以挂断在服务器上。例如,如果进程在正常关闭之前退出,就会发生这种情况。