grpc-java icon indicating copy to clipboard operation
grpc-java copied to clipboard

stub.withWaitForReady().withDeadline is masking the underlying exceptions

Open mohit-0109 opened this issue 1 year ago • 1 comments

try {
  stub.withWaitForReady().withDeadline().hello();
} catch(StatusRuntimeException e) {
  // always receiving DEADLINE_EXCEEDED as status code if server is unavailable or client certs are invalid
}

There is no way to distinguish the underlying cause of failure , say if the failure is due to SSLHanshake or server genuinely not being available.

As an alternative, without using withWaitForReady() we are receiving UNAVAILABLE code in StatusRuntimeException which wraps the underlying cause say for example the SSLHandshake exception. Looking at the UNAVAILABLE code how can we safely take a call if we to reattempt connection, as we do not want to reattempt the connection in SSLException scenarios?

mohit-0109 avatar Dec 14 '23 11:12 mohit-0109

Drive-by comment: What needs to happen here is we enhance DelayedStream/PendingStream to remember the last pick failure and then add it during appendTimeoutInsight() if there is no real stream. We've been aware of this shortcoming, but most people aren't using waitForReady(). Then you'd get better error information without doing anything in particular (as long as DEADLINE_EXCEEDED still triggers). #6569 might be related.

ejona86 avatar Dec 19 '23 21:12 ejona86