Hey Xiaojun, As far as I understand, this happens down the stack, before your server handlers are triggered. And it's normal for gRPC to fail RPC on errors, including demarshalling errors.
What you'd need is to insert your code prior to protobuf getting unpacked, and handle it manually. Take a look at this StackOverflow answer written by on of our engineers: soap - How can I fully intercept a gRPC java unary call, on the client, and on the server? - Stack Overflow <https://stackoverflow.com/a/54228051/11697987>, and this issue: Access unparsed data in interceptor? · Issue #1403 · grpc/grpc-java <https://github.com/grpc/grpc-java/issues/1403>. Best regards, Sergii On Tuesday, July 26, 2022 at 7:22:52 AM UTC-7 Xiaojun Zhang wrote: > We had an issue today where gRPC server received a corrupted protobuf > message. > Then it seemed to disconnect the client. While i can't reproduce this > error is there a way to catch such exception on the service side? i.e. in > onNext() > > 2022-07-26 10:39:15.006 ERROR 60123 --- [ult-executor-39] > io.grpc.internal.SerializingExecutor : Exception while executing > runnable > io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1MessagesAvailable@3a33e25f > > io.grpc.StatusRuntimeException: INTERNAL: Invalid protobuf byte sequence > at io.grpc.Status.asRuntimeException(Status.java:525) > ~[grpc-api-1.35.0.jar:1.35.0] > at > io.grpc.protobuf.lite.ProtoLiteUtils$MessageMarshaller.parse(ProtoLiteUtils.java:218) > > ~[grpc-protobuf-lite-1.35.0.jar:1.35.0] > at > io.grpc.protobuf.lite.ProtoLiteUtils$MessageMarshaller.parse(ProtoLiteUtils.java:118) > > ~[grpc-protobuf-lite-1.35.0.jar:1.35.0] > at > io.grpc.MethodDescriptor.parseRequest(MethodDescriptor.java:307) > ~[grpc-api-1.35.0.jar:1.35.0] > at > io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.messagesAvailableInternal(ServerCallImpl.java:309) > > ~[grpc-core-1.35.0.jar:1.35.0] > at > io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.messagesAvailable(ServerCallImpl.java:292) > > ~[grpc-core-1.35.0.jar:1.35.0] > at > io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1MessagesAvailable.runInContext(ServerImpl.java:782) > > ~[grpc-core-1.35.0.jar:1.35.0] > at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) > ~[grpc-core-1.35.0.jar:1.35.0] > at > io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) > ~[grpc-core-1.35.0.jar:1.35.0] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > > [na:1.8.0_71] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > > [na:1.8.0_71] > at java.lang.Thread.run(Thread.java:745) [na:1.8.0_71] > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/0a808c2e-f3e4-4041-8bf5-aca04021cdc1n%40googlegroups.com.
