From 4f4cd4647d58d29ff3c8d1586cf0785684a4783c Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Fri, 13 Mar 2026 00:59:59 +0100 Subject: [PATCH] [fix](trx-client): reduce remote spectrum timeout churn Relax the remote spectrum timeout, poll at the backend update cadence, and stop polling when no spectrum subscribers are connected. Co-authored-by: OpenAI Codex Signed-off-by: Stan Grams --- src/trx-client/src/remote_client.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/trx-client/src/remote_client.rs b/src/trx-client/src/remote_client.rs index 82e0ed8..0234ccd 100644 --- a/src/trx-client/src/remote_client.rs +++ b/src/trx-client/src/remote_client.rs @@ -22,7 +22,7 @@ use trx_protocol::{ClientCommand, ClientEnvelope, ClientResponse}; const DEFAULT_REMOTE_PORT: u16 = 4530; const CONNECT_TIMEOUT: Duration = Duration::from_secs(5); const IO_TIMEOUT: Duration = Duration::from_secs(15); -const SPECTRUM_IO_TIMEOUT: Duration = Duration::from_millis(1000); +const SPECTRUM_IO_TIMEOUT: Duration = Duration::from_secs(3); const MAX_JSON_LINE_BYTES: usize = 16 * 1024; const MAX_CONSECUTIVE_POLL_FAILURES: u32 = 3; @@ -42,7 +42,10 @@ impl RemoteEndpoint { } } -const SPECTRUM_POLL_INTERVAL: Duration = Duration::from_millis(40); +// Remote spectrum snapshots do not need to outpace the SDR-side producer. +// Polling at ~10 Hz avoids stacking unnecessary in-flight requests on slower +// links while still matching the typical backend update cadence. +const SPECTRUM_POLL_INTERVAL: Duration = Duration::from_millis(100); #[derive(Clone)] pub struct RemoteClientConfig { @@ -505,6 +508,9 @@ fn set_selected_rig_id(config: &RemoteClientConfig, value: Option) { } fn should_poll_spectrum(config: &RemoteClientConfig) -> bool { + if config.spectrum.receiver_count() == 0 { + return false; + } let selected = selected_rig_id(config); let Some(selected) = selected.as_deref() else { return true;