Skip to content

fix(http): time out idle connections at the connection limit - #7020

Merged
kuny0707 merged 3 commits into
tronprotocol:release_v4.8.3from
Little-Peony:hotfix/http-idle-timeout-at-connection-limit
Oct 13, 2026
Merged

kuny0707 merged 3 commits into
tronprotocol:release_v4.8.3from
Little-Peony:hotfix/http-idle-timeout-at-connection-limit

Conversation

@SeriousCoding789

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Time out idle HTTP connections once node.maxHttpConnectNumber (default 50) is reached: HttpService sets ConnectionLimit.setIdleTimeout(10_000).
  • Add ConnectionLimitTest. The idle timeout can be set through a @VisibleForTesting setter, so the test runs with 1 second instead of 10.

Why are these changes required?

At the connection limit Jetty stops accepting, and a connection that never sends a request holds its slot until the connector's 30-second idle timeout has fired twice (Jetty half-closes an idle connection before closing it), about 60 seconds. Meanwhile other HTTP / JSON-RPC clients are locked out. The new timeout applies only while the limit is reached and frees such a slot in about 20 seconds.

This PR has been tested by:

  • Unit Tests: ConnectionLimitTest passes in about 2 seconds and fails with a read timeout when the setIdleTimeout call is removed; SizeLimitHandlerTest, HttpApiAccessFilterTest, HttpInterceptorMetricsTest and checkstyle pass.

Follow up

None.

Extra details

  • No config key or default changes; HTTP behavior below the connection limit is unchanged.
  • While the limit is reached, Jetty applies the timeout to every open connection, not only to connections that have sent nothing: a keep-alive client that stays idle for more than 10 seconds between two requests on one connection is disconnected and has to reconnect. Time spent processing a request does not count as idle, so requests in progress are not affected.
  • Does not cover clients that trickle bytes to keep a connection active.
  • Split out of fix: harden start.sh #7003.

Connections that send nothing could hold every maxHttpConnectNumber slot until the connector's 30-second idle timeout and lock other clients out. When the limit is reached, the open connections now time out after 10 seconds of inactivity. Connections still being accepted at that moment keep the connector's default idle timeout.
Comment thread framework/src/test/java/org/tron/common/jetty/ConnectionLimitTest.java Outdated
@kuny0707
kuny0707 merged commit cfcd63e into tronprotocol:release_v4.8.3 Oct 13, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants