Repository navigation
Apply connect timeout to the CONNECT request - #6
Merged
Merged
Conversation
The CONNECT request was created with the Request defaults, so opening the tunnel always timed out after 10 seconds, regardless of the connect timeout in the ConnectContext. Use that timeout as the transfer and inactivity timeout of the CONNECT request.
kelunik
approved these changes
Oct 25, 2026
Member
|
Thanks! |
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.
TunnelSocket::tunnel()creates the CONNECT request withnew Request(...)and never sets a timeout, so opening the tunnel always uses theRequestdefaults of 10 seconds, whatever the caller configured.DefaultConnectionFactorypasses the request's TCP connect timeout to the connector viaConnectContext::withConnectTimeout(). That timeout is used for the TCP connection to the proxy, but not for the CONNECT request that follows. A proxy that is slow to reach the target (or never answers) therefore fails after 10 seconds even with a longer connect timeout, and can't be bounded by a shorter one either.This passes the connect timeout from the
ConnectContextthrough to the CONNECT request as its transfer and inactivity timeout, in bothHttp1TunnelConnectorandHttps1TunnelConnector. The CONNECT step gets the full connect timeout as its own window, the same way http-client applies the TCP connect and TLS handshake timeouts per step. Without aConnectContextthe timeout stays at 10 seconds, so the default behaviour is unchanged.The added test points the connector at a socket that accepts but never responds, with a 0.5 second connect timeout. It hits the 2 second test limit before this change and passes in about 0.5 seconds after it.
Found via Symfony's
AmpHttpClient, where proxied requests to unreachable hosts failed after 10 seconds instead of the configuredtimeout.CI fails before the tests run:
composer updatecan no longer resolve theleproxy/leproxydev dependency, because Composer blocks thereact/http0.8 versions it needs over security advisories (PKSA-7xc4-r5ry-fg9s, PKSA-wsbn-q9bd-w7z2, PKSA-kwfb-dvpm-qtpb). That also affects2.xand is unrelated to this change. Locally, with advisory blocking disabled, the full test suite and php-cs-fixer pass.