diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-24 15:39:29 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-24 15:39:29 +0300 |
| commit | a720367889cf8f54108deb1489cbcd06e0d3dfa7 (patch) | |
| tree | 79f2973a2d7c75e3723759b5e7c2b3ef254dec04 /src | |
| parent | 74076a83b157eecf845a1c9d45d8879540237e0a (diff) | |
fix: extend remote client handshake timeout for high-latency links
refs #753
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/mod.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs index 8845e446..67726e68 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -638,6 +638,25 @@ fn is_remote_client_process() -> bool { std::env::var(crate::remote::REMOTE_KEYBINDINGS_ENV_VAR).is_ok() } +/// Time to wait for the server's Welcome reply during the handshake. +/// +/// A local client talks to an already-connected server, so 5s is plenty. The +/// remote bridge client (`herdr --remote`) sits behind a fresh per-attach ssh +/// connection whose cold-connect (TCP + key exchange + auth) happens inside this +/// window; on a high-latency link that easily exceeds 5s, so it gets a far +/// larger budget. See issue #753. +const LOCAL_HANDSHAKE_READ_TIMEOUT: Duration = Duration::from_secs(5); +#[cfg(unix)] +const REMOTE_HANDSHAKE_READ_TIMEOUT: Duration = Duration::from_secs(60); + +fn handshake_read_timeout() -> Duration { + #[cfg(unix)] + if is_remote_client_process() { + return REMOTE_HANDSHAKE_READ_TIMEOUT; + } + LOCAL_HANDSHAKE_READ_TIMEOUT +} + fn requested_keybindings() -> ClientKeybindings { match std::env::var(crate::remote::REMOTE_KEYBINDINGS_ENV_VAR) .ok() @@ -717,7 +736,7 @@ fn do_handshake( // Read Welcome. set_handshake_recv_timeout( stream, - Some(Duration::from_secs(5)), + Some(handshake_read_timeout()), "client handshake read timeout unavailable", )?; let welcome: ServerMessage = protocol::read_message(stream, MAX_FRAME_SIZE)?; |
