Skip to content

Conversation

@JamesNK
Copy link
Member

@JamesNK JamesNK commented Aug 26, 2022

Fixes #1861

// A channel is created once per client, lives forever, and the primary handler never changes.
// It's possible that long lived connections cause the client to miss out on DNS changes.
// Replicate the core benefit of a handler lifetime (periodic connection recreation)
// by setting PooledConnectionLifetime to handler lifetime.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @JamesNK to address this issue based on our offline discussion. Leave few comments here:

  1. Since we cache channel per typed/named client (no matter the client is transient or singleton), and use PooledConnectionLifetime to control handler lifetime, we are only using httpclientfactory as configuration API, the httpclientfactory handler pool is redundant in this scenario. I think we should work with runtime team to make httpclientfactory just as configuration API.
  2. With caching channel and use PooledConnectionLifetime, would you mind to share more details on why we DI GrpcClientFactory as transient rather than singleton (same as DefatultHttpClientFactory)?
    services.TryAddTransient<GrpcClientFactory, DefaultGrpcClientFactory>();

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With caching channel and use PooledConnectionLifetime, would you mind to share more details on why we DI GrpcClientFactory as transient rather than singleton (same as DefatultHttpClientFactory)?
services.TryAddTransient<GrpcClientFactory, DefaultGrpcClientFactory>();

So the current IServiceProvider scope is injected into the factory.

@JamesNK JamesNK force-pushed the jamesnk/factory-pooled-connection-lifetime branch from 6605a84 to e994f23 Compare August 27, 2022 05:38
@JamesNK JamesNK merged commit 2116d1e into grpc:master Aug 29, 2022
@JamesNK JamesNK deleted the jamesnk/factory-pooled-connection-lifetime branch August 29, 2022 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider setting SocketsHttpHandler.PooledConnectionLifetime in factory

3 participants