Robin Green
Robin Green

Reputation: 33063

Handling network errors in 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?

Upvotes: 3

Views: 845

Answers (1)

user675693
user675693

Reputation: 335

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.

Upvotes: 1

Related Questions