我正在尝试运行路由示例,但是当客户端开始连接到服务器(blockingStub.getFeature(request)
)时,它会挂起。如果我停止客户端(终端中的ctrl + c)错误发生(见下文)。
有人知道可能出现什么问题吗?
堆栈追踪:
候机楼-服务器:
./gradlew routeGuideServer
:grpc-core:compileJava UP-TO-DATE
:grpc-core:animalSniffer
...
May 06, 2015 4:56:06 PM io.grpc.examples.routeguide.RouteGuideServer start
INFO: Server started, listening on 8980
// server is started; now running client
候机楼的客户端:
./gradlew routeGuideClient
:grpc-core:compileJava UP-TO-DATE
:grpc-core:animalSniffer
...
:grpc-examples:classes UP-TO-DATE
May 06, 2015 4:56:51 PM io.grpc.examples.routeguide.RouteGuideClient info
INFO: *** GetFeature: lat=409,146,138 lon=-746,188,906
// at this point everythings hangs
使用CTRL + C停止客户端会导致服务器错误
May 06, 2015 4:57:50 PM io.netty.channel.DefaultChannelPipeline$TailContext exceptionCaught
WARNING: An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.io.IOException: An existing connection was forcibly closed by the remote host
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:192)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379)
at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:311)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:854)
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:242)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:115)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:510)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:467)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:381)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:703)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
答案 0 :(得分:2)
这可能是一个错误;虽然客户端确实做了一些睡眠,但没有理由它应该挂起。我不能重现这个问题。
服务器端的异常可能是相关的,因为通常客户端会执行正常关闭,这不会产生该异常。但是,如果客户端无法正常关闭连接,那么您将收到警告。
我确实在昨天的grpc-io@googlegroups.com上看到了我所假设的消息,但没有机会回复。我创建了an issue来跟踪错误。