Skip to content

HTTP/2 pings don't work if the connection lifetime is zero #113532

@MihaZupan

Description

@MihaZupan

We have this optimization in the connection pool manager where we'll avoid storing connections that have the lifetime set to 0.

// As an optimization, we can sometimes avoid the overheads associated with
// storing connections. This is possible when we would immediately terminate
// connections anyway due to either the idle timeout or the lifetime being
// set to zero, as in that case the timeout effectively immediately expires.
// However, we can only do such optimizations if we're not also tracking
// connections per server, as we use data in the associated data structures
// to do that tracking.
bool avoidStoringConnections =
settings._maxConnectionsPerServer == int.MaxValue &&
(settings._pooledConnectionIdleTimeout == TimeSpan.Zero ||
settings._pooledConnectionLifetime == TimeSpan.Zero);

This also controls whether we create the heartbeat timer, which does the HTTP/2 ping sending and timeout enforcement.
Since we don't account for KeepAlivePingDelay being set, a config that sets Lifetime/Timeout to 0 will also ignore the ping options.

Technically a bug, but the use cases where you'd care about this are likely very niche.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions