Polly (.Net) 默认重试哪些 HTTP 错误代码?
What HTTP error codes are retried by Polly (.Net) by default?
我知道我可以指定 HTTP 错误代码列表(例如 408、502、503 等)我想使用 Polly 重试,但是这些代码的列表是什么?如果指定 none 是否默认重试?
What is the list of [Http status] codes that would be retried by default [by Polly] if none is specified?
Polly 本身不包含重试内容的内置定义:您作为用户 specify that when defining a policy。
Polly with HttpClientFactory(在 .Net Core 中使用 StartUp
中的 services.AddHttpClient(...).AddTransientHttpErrorPolicy(...)
)根据 Polly with HttpClientFactory documentation:
重试以下项目
- 网络故障(System.Net.Http.HttpRequestException)
- HTTP 5XX 状态代码(服务器错误)
- HTTP 408 状态码(请求超时)
当您将鼠标悬停在该方法上时 should also be shown in the intellisense。
.HandleTransientHttpError()
方法可通过 Polly.Extensions.Http
package also handles the same set of exceptions and status codes 获得。
我知道我可以指定 HTTP 错误代码列表(例如 408、502、503 等)我想使用 Polly 重试,但是这些代码的列表是什么?如果指定 none 是否默认重试?
What is the list of [Http status] codes that would be retried by default [by Polly] if none is specified?
Polly 本身不包含重试内容的内置定义:您作为用户 specify that when defining a policy。
Polly with HttpClientFactory(在 .Net Core 中使用 StartUp
中的 services.AddHttpClient(...).AddTransientHttpErrorPolicy(...)
)根据 Polly with HttpClientFactory documentation:
- 网络故障(System.Net.Http.HttpRequestException)
- HTTP 5XX 状态代码(服务器错误)
- HTTP 408 状态码(请求超时)
当您将鼠标悬停在该方法上时 should also be shown in the intellisense。
.HandleTransientHttpError()
方法可通过 Polly.Extensions.Http
package also handles the same set of exceptions and status codes 获得。