Skip to content

Make tunnel-client max HTTP content length configurable (#3034)#3183

Open
daguimu wants to merge 1 commit into
alibaba:masterfrom
daguimu:fix/tunnel-jfr-content-length-3034
Open

Make tunnel-client max HTTP content length configurable (#3034)#3183
daguimu wants to merge 1 commit into
alibaba:masterfrom
daguimu:fix/tunnel-jfr-content-length-3034

Conversation

@daguimu
Copy link
Copy Markdown
Contributor

@daguimu daguimu commented Apr 29, 2026

Problem

When the Arthas Web Console is connected through a tunnel-server and a user clicks Download on a JFR recording larger than 10 MB, the download silently fails and the browser receives a body containing the literal text error. The tunnel-server logs:

com.alibaba.arthas.deps.io.netty.handler.codec.http.TooLongHttpContentException:
    Response entity too large: DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
  at io.netty.handler.codec.http.HttpObjectAggregator.handleOversizedMessage(HttpObjectAggregator.java:275)

Recordings up to 10 MB download fine; anything larger is truncated to the error string.

Root Cause

tunnel-client/ProxyClient configures Netty's HttpObjectAggregator with the shared ArthasConstants.MAX_HTTP_CONTENT_LENGTH = 10 MB constant. When the agent's local Arthas HTTP server emits a response exceeding 10 MB (such as a JFR file), the aggregator rejects it before the bytes can reach the tunnel-server, and the proxy falls back to its error payload.

Fix

Introduce a JVM system property arthas.tunnel.client.max-http-content-length (in bytes) that overrides the cap used by ProxyClient only. The shared MAX_HTTP_CONTENT_LENGTH constant is left untouched, so unrelated consumers (WebSocket frame limit, ObjectView size limit, etc.) keep their existing semantics.

  • Default remains 10 MB - existing deployments behave identically.
  • Setting -Darthas.tunnel.client.max-http-content-length=104857600 (100 MB) lets users download larger JFR recordings.
  • Invalid values (non-numeric, zero, negative) fall back to the default rather than failing fast, matching the lenient parsing already used elsewhere in arthas-common.

Files touched:

  • common/src/main/java/com/taobao/arthas/common/ArthasConstants.java - add property name + getTunnelClientMaxHttpContentLength() helper.
  • tunnel-client/src/main/java/com/alibaba/arthas/tunnel/client/ProxyClient.java - call the helper instead of the hard-coded constant.
  • tunnel-client/pom.xml - add JUnit test scope (matches tunnel-common).

Tests Added

tunnel-client/src/test/java/com/taobao/arthas/common/ArthasConstantsTest.java covers:

  • Defaults to MAX_HTTP_CONTENT_LENGTH when the property is unset.
  • Honours a configured value (100 MB).
  • Falls back to default on non-numeric input.
  • Falls back to default on zero/negative input.

mvn -pl common,tunnel-client -am clean test passes locally (4 new tests, 0 failures).

Impact

  • Backward compatible - default behavior unchanged.
  • Scoped to the tunnel-client HTTP aggregator path identified in the issue; does not alter the MAX_HTTP_CONTENT_LENGTH constant or the many other call sites that depend on its current value.
  • Operators downloading large JFR recordings can opt in by setting the new system property on the agent JVM.

Closes #3034

The tunnel-client `ProxyClient` aggregates HTTP responses with a fixed
10 MB cap (`ArthasConstants.MAX_HTTP_CONTENT_LENGTH`). When a user
downloads a JFR recording larger than 10 MB through the tunnel-server,
Netty's `HttpObjectAggregator` aborts with `TooLongHttpContentException`
and the browser receives only the literal text "error".

Introduce a system property `arthas.tunnel.client.max-http-content-length`
that overrides the limit for the tunnel-client HTTP aggregator only.
Default behavior (10 MB) is unchanged; operators can raise the cap when
streaming large recordings without affecting the WebSocket frame or
object-view size limits that share the legacy constant.

Closes alibaba#3034
hengyunabc added a commit that referenced this pull request Apr 29, 2026
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.

Unable to download JFR recordings larger than 10MB via Tunnel Server

1 participant