Skip to content

fix(triple): ping idle HTTP/2 connections on the server - #3910

Open
AsperforMias wants to merge 2 commits into
apache:developfrom
AsperforMias:fix/triple-server-keepalive
Open

AsperforMias wants to merge 2 commits into
apache:developfrom
AsperforMias:fix/triple-server-keepalive

Conversation

@AsperforMias

@AsperforMias AsperforMias commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #3900
Part of #3898

The Triple server configured no HTTP/2 keepalive. A consumer that went away without closing its connection (process suspended, network partition, host failure) left the provider's handlers running until the operating system gave up on the TCP connection. The consumer side already pings idle connections (10 s / 20 s by default), so it noticed a vanished provider within 30 s; the provider never noticed a vanished consumer.

Changes

  • The server reads TripleConfig.KeepAliveInterval and KeepAliveTimeout, the fields that already configure the consumer, and sets them on http.Server.HTTP2: a connection that receives nothing for the interval is pinged, and it is closed when the ping goes unanswered within the timeout, which cancels its handlers.
  • The defaults are the consumer's, 10 s and 20 s. The server accepts the same values as the consumer, with net/http's meaning: an interval of 0 or less disables the pings, and a timeout of 0 or less uses the default of 15 s. A value that does not parse is rejected when the service is exported, before it is registered.
  • http.Server.HTTP2 is read by net/http's HTTP/2 server for TLS connections and by the cleartext h2c handler, so both are covered, including the HTTP/2 side of http2-and-http3.
  • The field comments in TripleConfig no longer say "for client".

Verification

  • TestServerClosesSilentHTTP2Connection: a peer answers the server's SETTINGS and first PING, is pinged again, then stops answering and is disconnected; over cleartext HTTP/2, over TLS, and on the TLS side of http2-and-http3. Each case fails without the setting on its start path.
  • TestServerHTTP2Config, TestResolveServerTransportRejectsInvalidKeepAlive and TestKeepAliveConfigSharedByConsumerAndProvider: defaults, configured values, zero and negative values accepted by both sides, and unparsable values rejected at export.
  • End to end with a Triple consumer holding a server stream and a bidi stream, suspended with SIGSTOP: with the provider built from develop, both handlers were still running 45 s later, when the consumer was killed; with this branch both handler contexts were canceled 29.4 s after the suspension.

Checklist

  • I confirm the target branch is develop
  • I have run make fmt to format my code
  • I have run make test to run local tests
  • I have added tests that prove my fix is effective or that my feature works

The Triple server set no HTTP/2 keepalive, so a consumer that went away
without closing its connection (suspended, network partition, host
failure) left the provider's handlers running until the operating system
gave up on the TCP connection.

The server now uses TripleConfig.KeepAliveInterval and KeepAliveTimeout,
which already configure the client, for http.Server.HTTP2: a connection
that receives nothing for the interval is pinged and closed when the ping
goes unanswered within the timeout, which cancels its handlers. The
defaults are the client's, 10s and 20s, and an interval of 0 disables
the pings. The setting covers cleartext and TLS HTTP/2. Invalid values
are rejected when the service is exported.
@codecov-commenter

codecov-commenter commented Nov 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.12%. Comparing base (60d1c2a) to head (95ff43e).
⚠️ Report is 1073 commits behind head on develop.

Files with missing lines Patch % Lines
protocol/triple/triple_protocol/server.go 81.81% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #3910       +/-   ##
============================================
+ Coverage    46.76%   61.12%   +14.35%     
============================================
  Files          295      515      +220     
  Lines        17172    42447    +25275     
============================================
+ Hits          8031    25945    +17914     
- Misses        8287    14693     +6406     
- Partials       854     1809      +955     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

KeepAliveInterval and KeepAliveTimeout configure both sides, and the
client passes them to its HTTP/2 transport as they are. The server
rejected a zero timeout and negative values that the client accepts, so
a process exporting a provider with the same configuration failed to
register it. The server now rejects only values that do not parse and
hands the rest to net/http with the same meaning as on the client: an
interval of 0 or less disables the pings, a timeout of 0 or less uses
the default of 15s.
@sonarqubecloud

Copy link
Copy Markdown

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.

3 participants