What HTTP error codes are retried by Polly (.Net) by default?
Asked Answered
W

1

15

I know I can specify the list of HTTP error codes (e.g. 408, 502, 503, etc. ) I would like to get retried using Polly, but what is the list of these codes that would be retried by default if none is specified?

Whoredom answered 14/2, 2019 at 22:8 Comment(0)
N
15

What is the list of [Http status] codes that would be retried by default [by Polly] if none is specified?

Polly on its own contains no built-in definitions of what it retries, you as the user specify that when defining a policy.

Polly with HttpClientFactory (using services.AddHttpClient(...).AddTransientHttpErrorPolicy(...) in StartUp in .Net Core) retries the following items, per the Polly with HttpClientFactory documentation:

  • Network failures (System.Net.Http.HttpRequestException)
  • HTTP 5XX status codes (server errors)
  • HTTP 408 status code (request timeout)

This should also be shown in the intellisense when you hover over the method.

The HandleTransientHttpError() method available via the Polly.Extensions.Http package also handles the same set of exceptions and status codes.

Nisus answered 15/2, 2019 at 6:13 Comment(3)
It seems that polly throws only about timedoutexceptions. Not about the other error codesAntiperistalsis
Can you please have a look at this ?Antiperistalsis
to retry all 5xx errors is too broad list(e.g. 501 NotImplemented doesn’t make sense to retry). Consider #51770571 list instead and retryHttpStatusCodesList implementation from #61019507 questionDjerba

© 2022 - 2024 — McMap. All rights reserved.