From ec460496d853d3c1480d9e5e4791071a28ddf880 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sat, 15 Nov 2025 11:09:49 +0100 Subject: [PATCH] Remove blocking TCP connectivity tests for fast startup Eliminates test_tcp_connectivity function that was causing 5-10 second startup delays. ZMQ connections are non-blocking and we rely entirely on heartbeat mechanism for connectivity detection. This restores fast dashboard startup time. --- agent/Cargo.toml | 2 +- dashboard/Cargo.toml | 2 +- dashboard/src/communication/mod.rs | 25 ------------------------- shared/Cargo.toml | 2 +- 4 files changed, 3 insertions(+), 28 deletions(-) diff --git a/agent/Cargo.toml b/agent/Cargo.toml index ec38e1d..097c25b 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.71" +version = "0.1.72" edition = "2021" [dependencies] diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 05c8861..0c851da 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.71" +version = "0.1.72" edition = "2021" [dependencies] diff --git a/dashboard/src/communication/mod.rs b/dashboard/src/communication/mod.rs index 99e63bc..18ff944 100644 --- a/dashboard/src/communication/mod.rs +++ b/dashboard/src/communication/mod.rs @@ -71,12 +71,6 @@ impl ZmqConsumer { pub async fn connect_to_host(&mut self, hostname: &str, port: u16) -> Result<()> { let address = format!("tcp://{}:{}", hostname, port); - // First test basic TCP connectivity to the port - if let Err(e) = self.test_tcp_connectivity(hostname, port).await { - error!("TCP connectivity test failed for {}: {}", address, e); - return Err(e); - } - match self.subscriber.connect(&address) { Ok(()) => { info!("Connected to agent at {}", address); @@ -90,25 +84,6 @@ impl ZmqConsumer { } } - /// Test TCP connectivity to a host and port with timeout - async fn test_tcp_connectivity(&self, hostname: &str, port: u16) -> Result<()> { - let timeout = std::time::Duration::from_secs(3); - - match tokio::time::timeout(timeout, tokio::net::TcpStream::connect((hostname, port))).await { - Ok(Ok(_stream)) => { - debug!("TCP connectivity test passed for {}:{}", hostname, port); - Ok(()) - } - Ok(Err(e)) => { - debug!("TCP connectivity test failed for {}:{}: {}", hostname, port, e); - Err(anyhow::anyhow!("TCP connection failed: {}", e)) - } - Err(_) => { - debug!("TCP connectivity test timed out for {}:{}", hostname, port); - Err(anyhow::anyhow!("TCP connection timed out")) - } - } - } /// Connect to predefined hosts using their configuration pub async fn connect_to_predefined_hosts(&mut self, hosts: &std::collections::HashMap) -> Result<()> { diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 94fc4fe..c4e6c0b 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.71" +version = "0.1.72" edition = "2021" [dependencies]