Skip to content

Static HttpClient should use SocketsHttpHandler with a set pooled connection lifetime #1257

@TimHess

Description

@TimHess

As a follow-up to #21, any long-lived HttpClient should be configured with a pooled connection lifetime so that DNS records are less likely to be stale:

var handler = new SocketsHttpHandler
{
    PooledConnectionLifetime = TimeSpan.FromMinutes(15) // Recreate every 15 minutes
};
var sharedClient = new HttpClient(handler);

https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines#dns-behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component/CommonReleaseLine/3.xIdentified as a feature/fix for the 3.x release lineReleaseLine/4.xIdentified as a feature/fix for the 4.x release lineType/enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions