Skip to content

Consider using IHttpClientFactory internally for better HttpClient lifecycle management #500

@tcortega

Description

@tcortega

Currently, ClientFactory.GetClient() accepts an HttpClient instance as a parameter. This can lead to HttpClient lifetime issues when using dependency injection, as the IRpcClient may hold onto the HttpClient reference.

When registering IRpcClient as Singleton with a provided HttpClient, the HttpClient lives forever
When registering as Scoped/Transient, we lose connection pooling benefits

Consider accepting IHttpClientFactory instead of HttpClient, or provide an overload that accepts it. This would allow proper integration with .NET's dependency injection while maintaining optimal HttpClient lifecycle management.

https://learn.microsoft.com/en-us/dotnet/core/extensions/httpclient-factory

This would enable clean DI registration without worrying about HttpClient disposal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions