Getting IllegalStateException when starting the gr

2019-08-03 03:19发布

问题:

I am using grpc for my API development.

I was able to create and access API's so far.

All of a sudden I am seeing this exception stack trace continuously some 5 seconds after the "INFO: Server started. Listening on port 42420" message is displayed.

I have deployed this project and bringing the server up on a GCE instance. Please let me know the reason and solution for this issue if anyone have faced it before.

Stack trace:

May 11, 2016 7:14:20 AM io.grpc.internal.AbstractServerStream deframeFailed
WARNING: Exception processing message
java.lang.IllegalStateException: MessageDeframer is already closed
    at com.google.common.base.Preconditions.checkState(Preconditions.java:173)
    at io.grpc.internal.MessageDeframer.checkNotClosed(MessageDeframer.java:222)
    at io.grpc.internal.MessageDeframer.deframe(MessageDeframer.java:168)
    at io.grpc.internal.AbstractStream.deframe(AbstractStream.java:283)
    at io.grpc.internal.AbstractServerStream.inboundDataReceived(AbstractServerStream.java:199)
    at io.grpc.netty.NettyServerStream.inboundDataReceived(NettyServerStream.java:77)
    at io.grpc.netty.NettyServerHandler.onDataRead(NettyServerHandler.java:234)
    at io.grpc.netty.NettyServerHandler.access$300(NettyServerHandler.java:95)
    at io.grpc.netty.NettyServerHandler$FrameListener.onDataRead(NettyServerHandler.java:443)
    at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$FrameReadListener.onDataRead(DefaultHttp2ConnectionDecoder.java:236)
    at io.netty.handler.codec.http2.Http2InboundFrameLogger$1.onDataRead(Http2InboundFrameLogger.java:46)
    at io.netty.handler.codec.http2.DefaultHttp2FrameReader.readDataFrame(DefaultHttp2FrameReader.java:409)
    at io.netty.handler.codec.http2.DefaultHttp2FrameReader.processPayloadState(DefaultHttp2FrameReader.java:240)
    at io.netty.handler.codec.http2.DefaultHttp2FrameReader.readFrame(DefaultHttp2FrameReader.java:147)
    at io.netty.handler.codec.http2.Http2InboundFrameLogger.readFrame(Http2InboundFrameLogger.java:39)
    at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder.decodeFrame(DefaultHttp2ConnectionDecoder.java:102)
    at io.netty.handler.codec.http2.Http2ConnectionHandler$FrameDecoder.decode(Http2ConnectionHandler.java:515)
    at io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:575)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:360)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:244)
    at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
    at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:163)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:155)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:950)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:125)
    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$5.run(SingleThreadEventExecutor.java:742)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

回答1:

I was having the similar issue because in my service implementation I had something like below,

@Override
public void myMethod(
  //super.myMethod(myRequest, responseObserver);// removing this line resolved my issue.
  ...
  responseObserver.onNext(response); // I had exception here because of the super.myMethod call.
  ...
}

I thought it was good to call the base implementation and then do my implementation. But seems like that was not a good idea.

I hope this saves someone's time.



回答2:

The error seems like this issue. The user from the issue was experiencing the exception due to a service clients were accessing but was unimplemented, but there are other possible triggers. The fix is almost committed and it should be fixed in the next release.