Add HTTP/2 keepalive options to ConnectionOptions#430
Merged
yoshidan merged 1 commit intoyoshidan:mainfrom Mar 18, 2026
Merged
Conversation
Add http2_keep_alive_interval, keep_alive_timeout, and keep_alive_while_idle fields to ConnectionOptions in gax, and expose them through each gRPC service crate's config structs so users can configure HTTP/2 PING-based keepalive to detect dead connections promptly.
Owner
|
LGTM. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
http2_keep_alive_interval,keep_alive_timeout, andkeep_alive_while_idlefields toConnectionOptionsingax, mapped to tonicEndpointmethodsChannelConfig, spanner adminAdminClientConfig, bigqueryChannelConfig, artifact-registryClientConfig)ConnectionOptionsdirectly, so no additional changes neededMotivation
Without HTTP/2 keepalive, when an intermediate network device (load balancer, NAT, etc.) silently drops a connection, the client cannot detect the dead connection until the TCP retransmission timeout (~13-30
minutes depending on OS settings). This is particularly problematic for long-lived streaming RPCs like Pub/Sub streaming pull.
HTTP/2 PING frames allow the client to detect dead connections within
interval + timeout(e.g., 50 seconds with 30s interval + 20s timeout) instead of waiting for TCP-level timeouts.Google's official Go client configures HTTP/2 keepalive for this reason. tonic 0.14 already supports these settings on
Endpointwithout additional feature flags.All defaults are
None(keepalive disabled), so this is a non-breaking behavioral change. Users opt in by setting the fields explicitly.Note: adding new fields to
ConnectionOptionsand other config structs is a source-breaking change for users who construct them with struct literals without..Default::default().Example
Note
@yoshidan
All new keepalive fields default to
None(keepalive disabled) to preserve backward compatibility. An alternative would be to set sensible defaults (e.g., 30s interval, 20s timeout, idle=true) out of the box, which would benefit all users without requiring explicit configuration. Happy to change this if you prefer enabling keepalive by default.Related issues