[fix](trx-client): reduce events source latency to <1 s

Three causes of >30 s SSE stalls:

1. SPECTRUM_IO_TIMEOUT was 300 ms — transient server jitter triggered
   false-positive spectrum failures and immediate TCP disconnects.
   Raised to 1 s to tolerate brief load spikes.

2. reconnect_delay was never reset after a successful TCP connect, so
   after a few spectrum-induced disconnects the backoff reached 10 s.
   Each new disconnect then cost 10 s of stale SSE state, and several
   cycles accumulated to >30 s.  Reset to 1 s on every successful
   TCP connect so recovery stays fast.

3. SSE pings were emitted as comments (": ping"), which EventSource
   never exposes to onmessage.  lastEventAt was therefore never updated
   by pings, causing the JS heartbeat to force-reconnect every ~20 s
   even on healthy, stable connections.  Changed to a named "ping"
   event and added es.addEventListener("ping", …) to update lastEventAt.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-03-09 22:13:53 +01:00
parent 824434e27e
commit 8cb6292c1d
4 changed files with 13 additions and 2 deletions
Generated
+3
View File
@@ -2460,6 +2460,7 @@ dependencies = [
"clap",
"cpal",
"dirs",
"flate2",
"opus",
"serde",
"serde_json",
@@ -2479,6 +2480,7 @@ dependencies = [
name = "trx-core"
version = "0.1.0"
dependencies = [
"flate2",
"serde",
"serde_json",
"tokio",
@@ -2591,6 +2593,7 @@ dependencies = [
"clap",
"cpal",
"dirs",
"flate2",
"num-complex",
"opus",
"pickledb",