Method IsTransient
IsTransient(Exception)
Gets a value indicating whether a request or hub connection failed because the service could not be reached or could not answer for the moment, so that it may work if it is made again. That is the case for:
- an HttpRequestException: the request could not be sent, or its response could not be read in full;
- an IOException from a response stream whose connection failed, such as a streaming response that ended before its end record
(on .NET 10 and later, an
HttpIOException); - a WebSocketException from a WebSocket that could not connect or whose connection closed without a close handshake, and a SocketException;
- an OperationCanceledException whose inner exception is a TimeoutException: the request timed out;
- a ServiceUnavailableApiException (503), such as one with ShortLivedStoreFull or CloudflareRangesUnavailable;
- an ApiException without an error code for a 502, 504 or 520 to 524 response: a gateway in front of the service, such as a reverse proxy or Cloudflare, could not get an answer from it.
Declaration
public static bool IsTransient(Exception exception)
Parameters
| Type | Name | Description |
|---|---|---|
| Exception | exception | The exception that the request or hub connection failed with. |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
Other exceptions are not transient by this measure, including an ApiException for a 408 (Request Timeout), which ASP.NET Core sends for a request body that arrives too slowly, and a TooManyRequestsApiException (429), whose RetryAfter says how long to wait.