fix: route WebSocket connections through the configured proxy#8
Merged
Daniel Elsner (delsner) merged 2 commits intomainfrom Mar 25, 2026
Merged
fix: route WebSocket connections through the configured proxy#8Daniel Elsner (delsner) merged 2 commits intomainfrom
Daniel Elsner (delsner) merged 2 commits intomainfrom
Conversation
ClientWebSocket instances in JobServer and ResultsServer never had Options.Proxy set, so they fell back to .NET's DefaultProxy which does not recognise wss:// and ws:// URI schemes — leaving WebSocket traffic unproxied in corporate proxy environments. Also fix RunnerWebProxy.IsBypassed / GetProxy to treat wss:// as https:// and ws:// as http://, so bypass rules and proxy selection work correctly for WebSocket URIs when the proxy is explicitly assigned.
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.
Problem
When running behind a corporate proxy,
ClientWebSocketconnections (used for live console feed streaming in bothJobServerandResultsServer) were not going through the proxy configured viahttp_proxy/https_proxyenvironment variables. This caused:502response from the proxy when attempting the WebSocket upgrade (the proxy intercepted the connection but didn't support forwarding the upgrade)NullReferenceExceptionretries inResultsServerafter the failed attempt set_websocketClienttonullMeanwhile, regular HTTP traffic (action downloads, API calls) correctly went through the proxy via
HttpClientHandlerFactory, socurlagainst the same endpoints worked fine.Root cause
Two issues in combination:
ClientWebSocket.Options.Proxywas never set inJobServer.InitializeWebsocketClientorResultsServer.InitializeWebsocketClient. The client fell back to .NET'sHttpClient.DefaultProxy, which does not recognisewss:///ws://URI schemes and silently bypasses the proxy for WebSocket connections.RunnerWebProxy.IsBypassedandGetProxyonly handledhttp/httpsschemes. For awss://URI,IsBypassedwould skip the "no proxy configured" short-circuit, andGetProxywould return the HTTP proxy address instead of the HTTPS proxy — both wrong.Fix
Options.Proxy = HostContext.WebProxyon every newly createdClientWebSocketinJobServerandResultsServer.RunnerWebProxy.IsBypassedto mapwss→httpsandws→httpbefore the scheme-based bypass checks.RunnerWebProxy.GetProxyto return_httpsProxyAddressforwss://URIs.Test plan
https_proxyset and verify WebSocket live-console streaming worksIsBypassedstill returnstruewhen no proxy address is set)no_proxybypass rules still apply correctly towss://URLs