Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

.net

polly

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?

like image 563
Jose Parra Avatar asked Feb 14 '19 22:02

Jose Parra


1 Answers

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 in-built 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.

like image 183
mountain traveller Avatar answered Nov 15 '22 13:11

mountain traveller