Skip to content
Discussion options

You must be logged in to vote
services.AddHttpClient(name, options =>
        {
            options.BaseAddress = new Uri(baseUrl);
        })
        .ConfigurePrimaryHttpMessageHandler(() =>
        {
            return new SocketsHttpHandler()
            {
                PooledConnectionLifetime = TimeSpan.FromMinutes(pooledConnedtionLifetimeInSeconds),
                PooledConnectionIdleTimeout = TimeSpan.FromMinutes(pooledConnectionIdleTimeout),
             
            };
        });

If I'm injecting IHttpClientFactory to my scoped/transient services and creating a client by factory.CreateClient(name). HttpFactory will reuse the HttpMessageHandler internally and will respect the pool time that has been conf…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@CarnaViire
Comment options

@davidfowl
Comment options

@Shayan-To
Comment options

@CarnaViire
Comment options

@Shayan-To
Comment options

Answer selected by akshay-zz
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants