Closed
Description
- Add cross-link to https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests
- Add examples of using Polly and Polly.Extensions.Http nuget PackageReference to a project. These are "opinionated" libraries to assist in transient fault handling.
- Incorporate @karelz feedback:
Unfortunately, this recommendation is not complete.
We need to warn users also about having long-existing HttpClient instances as that may lead to stale DNS usage. That can lead to non-functional connections.The recommendation should be either to:
- Use
HttpClient
instances as statics, which are recycled on regular basis, or - Use
HttpClientFactory
which works around this problem, or - Use static instances on .NET Core while setting
System.Net.Http.SocketsHttpHandler.PooledConnectionLifetime
.
- Use
- Regarding PooledConnectionLifetime, consider adding reference to Fix SocketsHttpHandler handling of pooling timeouts with max connections corefx#29822 which I believe fixes this in .NET Core 2.2 (Stephen Toub's commit is on May 22, 2018 and .NET Core 2.1 was released on May 30th, 2018). In other words, if your application needs to target .NET Core 2.1, this approach can probably run into problems described in that PR.
- Consider describing the benefits of using HttpClient via HttpClientFactory, including remarks in SockerHttpHandler https://docs.microsoft.com/en-us/dotnet/api/system.net.http.socketshttphandler?view=netcore-3.1#remarks
Originally posted by @jzabroski in dotnet/dotnet-api-docs#2315 (comment)