mirror of
https://github.com/openai/codex.git
synced 2026-11-25 07:23:22 +00:00
Refresh signed exec-server URLs on reconnect (#28374)
## Summary - add a provider API that supplies a fresh signed WebSocket URL for each remote exec-server connection - refresh the signed URL after disconnects and retry once when a handshake returns `401 Unauthorized` - allow `EnvironmentManager` consumers to register remote environments backed by the URL provider ## Tests - `just test -p codex-exec-server -E 'test(remote_websocket_client_refreshes_url_after_unauthorized_handshake) | test(remote_websocket_client_refreshes_url_after_disconnect)'` — 2 passed - `cargo check -p codex-core-api` — passed - `just fix -p codex-exec-server` — passed - `just fix -p codex-core-api` — no test targets; no-op - `just fmt` — passed - `just test -p codex-exec-server` — 187 passed; 32 unrelated macOS sandbox tests could not invoke nested `sandbox-exec` (`Operation not permitted`)
This commit is contained in:
1 parent
e922f46a0f
commit
ac3fe64100
2 files changed
+151
-10
No files matched your search
@@ -117,17 +117,8 @@ impl ExecServerClient {
|
||||
connect_timeout: DEFAULT_REMOTE_EXEC_SERVER_CONNECT_TIMEOUT,
|
||||
initialize_timeout: DEFAULT_REMOTE_EXEC_SERVER_INITIALIZE_TIMEOUT,
|
||||
};
|
||||
let bundle = provider.connect_bundle(identity.public_key()).await?;
|
||||
let (connection, options) =
|
||||
Self::open_noise_rendezvous_connection(NoiseRendezvousConnectArgs {
|
||||
bundle,
|
||||
harness_identity: identity,
|
||||
client_name: ENVIRONMENT_CLIENT_NAME.to_string(),
|
||||
connect_timeout: DEFAULT_REMOTE_EXEC_SERVER_CONNECT_TIMEOUT,
|
||||
initialize_timeout: DEFAULT_REMOTE_EXEC_SERVER_INITIALIZE_TIMEOUT,
|
||||
resume_session_id: None,
|
||||
})
|
||||
.await?;
|
||||
Self::open_initial_noise_rendezvous_connection(&provider, &identity).await?;
|
||||
Self::connect_with_recovery(connection, options, Some(reconnect_strategy)).await
|
||||
}
|
||||
crate::client_api::ExecServerTransportParams::StdioCommand {
|
||||
@@ -145,6 +136,40 @@ impl ExecServerClient {
|
||||
}
|
||||
}
|
||||
|
||||
async fn open_initial_noise_rendezvous_connection(
|
||||
provider: &Arc<dyn NoiseRendezvousConnectProvider>,
|
||||
identity: &NoiseChannelIdentity,
|
||||
) -> Result<(JsonRpcConnection, ExecServerClientConnectOptions), ExecServerError> {
|
||||
let open_connection = |bundle: NoiseRendezvousConnectBundle| {
|
||||
Self::open_noise_rendezvous_connection(NoiseRendezvousConnectArgs {
|
||||
bundle,
|
||||
harness_identity: identity.clone(),
|
||||
client_name: ENVIRONMENT_CLIENT_NAME.to_string(),
|
||||
connect_timeout: DEFAULT_REMOTE_EXEC_SERVER_CONNECT_TIMEOUT,
|
||||
initialize_timeout: DEFAULT_REMOTE_EXEC_SERVER_INITIALIZE_TIMEOUT,
|
||||
resume_session_id: None,
|
||||
})
|
||||
};
|
||||
let bundle = provider.connect_bundle(identity.public_key()).await?;
|
||||
match open_connection(bundle).await {
|
||||
Err(error)
|
||||
if matches!(
|
||||
&error,
|
||||
ExecServerError::WebSocketConnect { source, .. }
|
||||
if matches!(
|
||||
source,
|
||||
tokio_tungstenite::tungstenite::Error::Http(response)
|
||||
if response.status().as_u16() == 401
|
||||
)
|
||||
) =>
|
||||
{
|
||||
let bundle = provider.connect_bundle(identity.public_key()).await?;
|
||||
open_connection(bundle).await
|
||||
}
|
||||
result => result,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn connect_websocket(
|
||||
args: RemoteExecServerConnectArgs,
|
||||
) -> Result<Self, ExecServerError> {
|
||||
@@ -326,3 +351,7 @@ fn stdio_command_process(stdio_command: &StdioExecServerCommand) -> Command {
|
||||
command.process_group(0);
|
||||
command
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "client_transport_tests.rs"]
|
||||
mod tests;
|
||||
Reference in new issue
Block a user