Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling network errors in grpc-java

Tags:

grpc

grpc-java

How can I implement a strategy to detect and try to recover from network errors using gRPC-java? I know that UNAVAILABLE status can mean a network error, but that doesn't tell me what kind of network error it was - and UNAVAILABLE can also be sent back from the server.

In Java RMI we are admonished to pay attention to network problems and we can distinguish e.g. a ConnectionException which is a connection refused error. How can we do this with gRPC?

like image 674
Robin Green Avatar asked Nov 19 '25 11:11

Robin Green


1 Answers

You can know more details about the error from the cause and description of the Status. For example: if it is a connection error from client side, the cause probably will be an IO/SocketException; if it is a GO_AWAY sent from the server, the description will include the HTTP/2 error code.

like image 84
user675693 Avatar answered Nov 21 '25 08:11

user675693