Skip to content

HTTP/2 PING keepalive handler for idle connection protection#49095

Draft
jeet1995 wants to merge 1 commit intoAzure:mainfrom
jeet1995:squad/http2-ping-keepalive
Draft

HTTP/2 PING keepalive handler for idle connection protection#49095
jeet1995 wants to merge 1 commit intoAzure:mainfrom
jeet1995:squad/http2-ping-keepalive

Conversation

@jeet1995
Copy link
Copy Markdown
Member

@jeet1995 jeet1995 commented May 7, 2026

What

Extracts the HTTP/2 PING keepalive feature from PR #48420 as a standalone changeset.

Sends periodic PING frames on idle H2 parent channels to prevent L7 middleboxes (NAT gateways, firewalls, load balancers) from silently reaping connections.

Changes

Production (azure-cosmos):

  • \Http2PingHandler\ — ChannelDuplexHandler that sends PINGs when idle > configured interval
  • \Configs\ — \COSMOS.HTTP2_PING_HEALTH_ENABLED\ (default: true), \COSMOS.HTTP2_PING_INTERVAL_IN_SECONDS\ (default: 10s)
  • \ReactorNettyClient\ — installs PingHandler via doOnConnected on H2 parent channels
  • \IHttpClientInterceptor\ + plumbing for test hook injection

Test (azure-cosmos-tests):

  • \Http2PingKeepaliveTest\ — proves PINGs sent and ACKed on idle connections
  • \manual-http-network-fault\ TestNG suite + Maven profile

Test Results (Docker, --cap-add=NET_ADMIN)

\
RESULT: pingsSent=5, pingAcksReceived=10
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
\\

Related

Split from #48420

Extracts the HTTP/2 PING health probing feature from PR Azure#48420
(AzCosmos_HttpConnectionMaxLife) as a standalone changeset.

Production code:
- Http2PingHandler: sends PING frames on idle H2 parent channels
- Configs: COSMOS.HTTP2_PING_HEALTH_ENABLED + PING_INTERVAL_IN_SECONDS
- ReactorNettyClient: installs PingHandler via doOnConnected
- IHttpClientInterceptor: test hook for DNS resolver + doOnConnected
- HttpClientConfig/ConnectionPolicy/CosmosClientBuilder: interceptor plumbing

Test code:
- Http2PingKeepaliveTest: proves PINGs sent and ACKed on idle connections
- Http2PingFrameCounterHandler: test utility for counting PING ACK frames
- manual-http-network-fault TestNG suite + Maven profile

Verified in Docker (--cap-add=NET_ADMIN): 5 PINGs sent, 10 ACKs received.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the Cosmos label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant