Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 gRPC-java 实施策略来检测并尝试从网络错误中恢复?我知道 UNAVAILABLE 状态可能意味着网络错误,但这并不能告诉我它是哪种网络错误 - 而且 UNAVAILABLE 也可以从服务器发回。
在 Java RMI 中,我们被告知要注意网络问题,并且我们可以区分例如 ConnectionException,它是连接被拒绝错误。我们如何使用 gRPC 做到这一点?
您可以从状态的原因和描述中了解有关错误的更多详细信息。例如:如果是客户端连接错误,可能是IO/SocketException;如果是从服务器发送的 GO_AWAY,描述将包含 HTTP/2 错误代码。