반응형
Error
gRPC에서 Response에 대용량 데이터를 응답할 경우 아래와 같은 에러가 발생함.
Server Log
2024-01-12 17:26:11.165 WARN 41152 --- [-worker-ELG-3-3] i.g.n.s.i.grpc.netty.NettyServerHandler : Stream Error
io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception$StreamException: Stream closed before write could take place
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception.streamError(Http2Exception.java:172) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2RemoteFlowController$FlowState.cancel(DefaultHttp2RemoteFlowController.java:481) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2RemoteFlowController$1.onStreamClosed(DefaultHttp2RemoteFlowController.java:105) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2Connection.notifyClosed(DefaultHttp2Connection.java:356) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2Connection$ActiveStreams.removeFromActiveStreams(DefaultHttp2Connection.java:1003) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2Connection$ActiveStreams.deactivate(DefaultHttp2Connection.java:959) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2Connection$DefaultStream.close(DefaultHttp2Connection.java:512) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2Connection$DefaultStream.close(DefaultHttp2Connection.java:518) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler.closeStream(Http2ConnectionHandler.java:613) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$FrameReadListener.onRstStreamRead(DefaultHttp2ConnectionDecoder.java:455) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2InboundFrameLogger$1.onRstStreamRead(Http2InboundFrameLogger.java:80) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.readRstStreamFrame(DefaultHttp2FrameReader.java:516) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.processPayloadState(DefaultHttp2FrameReader.java:260) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2FrameReader.readFrame(DefaultHttp2FrameReader.java:160) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2InboundFrameLogger.readFrame(Http2InboundFrameLogger.java:41) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder.decodeFrame(DefaultHttp2ConnectionDecoder.java:181) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler$FrameDecoder.decode(Http2ConnectionHandler.java:378) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:438) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:508) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:447) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[grpc-netty-shaded-1.42.2.jar:1.42.2]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
Client Log
2024-01-12 17:26:11.149 INFO 34504 --- [-worker-ELG-1-2] io.grpc.internal.AbstractClientStream : Received data on closed stream
반응형
Solution
통신 중 stream이 끊겨서 발생한 것
아래 링크와 같이 request 시 대용량 데이터 전송시 에러 해결했던 것과 마찬가지로 클라이언트에도 설정이 필요함
https://momobob.tistory.com/108#google_vignette
클라이언트에서 데이터 수신시 4MB가 넘어가서 stream을 끊어버려서 발생한 것.
클라이언트의 application.yaml에도 아래와 같이 설정값 추가하면 됨.
grpc:
client:
test:
address: 'static://127.0.0.1:9090'
negotiationtype: plaintext
max-inbound-message-size: 15000000 #byte (15MB)
Thank you!
반응형