From acf5ea8ebe8bc320cfa13537cfaf0e4059f1ea50 Mon Sep 17 00:00:00 2001 From: Riz Ashraf Date: Sun, 20 Sep 2026 23:02:55 +0100 Subject: [PATCH] fix(stub): Prevent infinite reconnect loop causing port exhaustion - Added a break statement when send_task exits (STDIN closed). - Increased reconnect delay from 50ms to 1 second to prevent ephemeral port exhaustion when the server repeatedly drops connections. --- stub/src/main.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/stub/src/main.rs b/stub/src/main.rs index 86e387b..8bb836f 100644 --- a/stub/src/main.rs +++ b/stub/src/main.rs @@ -117,20 +117,23 @@ fn main() -> Result<(), Box> { }); tokio::select! { - _ = shutdown_rx.recv() => { tokio::time::sleep(tokio::time::Duration::from_millis(50)).await; + _ = shutdown_rx.recv() => { + tokio::time::sleep(tokio::time::Duration::from_millis(50)).await; tracing::info!("Shutdown received while connected"); - + break; } _ = &mut send_task => { tracing::error!("Send task exited"); - tokio::time::sleep(tokio::time::Duration::from_millis(50)).await; recv_task.abort(); + tokio::time::sleep(tokio::time::Duration::from_millis(50)).await; + recv_task.abort(); + break; } _ = &mut recv_task => { tracing::error!("Recv task exited"); send_task.abort(); } } - tokio::time::sleep(tokio::time::Duration::from_millis(50)).await; + tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; } Err(e) => { tracing::error!("Failed to connect via WSS: {}", e);