Honor configured proxies for realtime WebSocket connections (#47101)

## Why

Realtime WebSockets connected directly, bypassing the configured proxy policy for Voice's WebRTC sideband.

## What changed

Pass the configured `HttpClientFactory` into `RealtimeWebsocketClient` and connect through the shared `WebSocketConnector`. Add support for supplying an existing Rustls configuration to preserve custom CA handling and Windows platform trust.

## Testing

Add an integration test that enables `respect_system_proxy`, starts a WebRTC conversation, and verifies that the sideband establishes its session through an HTTP `CONNECT` proxy and closes successfully.

GitOrigin-RevId: d974c9275d7fe29f388d56a9d5d8ce0c483eb8d0
This commit is contained in:
Celia Chen
2026-09-21 20:05:21 +00:00
committed by copyberry
parent 8e7f50cba9
commit 142360dac8
7 changed files with 324 additions and 65 deletions
+8 -1
View File
@@ -31,6 +31,7 @@ use codex_api::build_session_headers;
use codex_api::map_api_error;
use codex_config::config_toml::RealtimeWsMode;
use codex_config::config_toml::RealtimeWsVersion;
use codex_http_client::HttpClientFactory;
use codex_login::CodexAuth;
use codex_login::default_client::add_originator_header;
use codex_login::default_client::default_headers;
@@ -507,6 +508,7 @@ struct ConversationState {
struct RealtimeStart {
api_provider: ApiProvider,
http_client_factory: HttpClientFactory,
realtime_sideband_base_url: Option<String>,
extra_headers: Option<HeaderMap>,
client_managed_handoffs: bool,
@@ -600,6 +602,7 @@ impl RealtimeConversationManager {
async fn start_inner(&self, start: RealtimeStart) -> CodexResult<RealtimeStartOutput> {
let RealtimeStart {
api_provider,
http_client_factory,
realtime_sideband_base_url,
extra_headers,
client_managed_handoffs,
@@ -653,7 +656,7 @@ impl RealtimeConversationManager {
audio_rx,
};
let client = RealtimeWebsocketClient::new(api_provider);
let client = RealtimeWebsocketClient::new(api_provider, http_client_factory);
let client = match realtime_sideband_base_url {
Some(base_url) => client.with_webrtc_sideband_base_url(base_url),
None => client,
@@ -1204,6 +1207,7 @@ pub(crate) async fn handle_start(
struct PreparedRealtimeConversationStart {
api_provider: ApiProvider,
http_client_factory: HttpClientFactory,
realtime_sideband_base_url: Option<String>,
extra_headers: Option<HeaderMap>,
client_managed_handoffs: bool,
@@ -1345,6 +1349,7 @@ async fn prepare_realtime_start(
}
Ok(PreparedRealtimeConversationStart {
api_provider,
http_client_factory: config.http_client_factory(),
realtime_sideband_base_url,
extra_headers: Some(extra_headers),
client_managed_handoffs: params.client_managed_handoffs,
@@ -1567,6 +1572,7 @@ async fn handle_start_inner(
) -> CodexResult<()> {
let PreparedRealtimeConversationStart {
api_provider,
http_client_factory,
realtime_sideband_base_url,
extra_headers,
client_managed_handoffs,
@@ -1595,6 +1601,7 @@ async fn handle_start_inner(
};
let start = RealtimeStart {
api_provider,
http_client_factory,
realtime_sideband_base_url,
extra_headers,
client_managed_handoffs,