Skip to content

fix(srtla-core): retry a timed-out link every second before slowing down - #22

Merged
datagutt merged 1 commit into
mainfrom
fix/fast-reconnect-retry
Sep 24, 2026
Merged

datagutt merged 1 commit into
mainfrom
fix/fast-reconnect-retry

Conversation

@datagutt

@datagutt datagutt commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Supersedes #18. It keeps the fast retry window from that PR, drops its config knobs, and fixes the retry count reset that kept the window from working as described.

Why

SRT drops the session after 5 s of silence. An established link that timed out got its first retry 5 s later, so a sub-second blip (a bumped USB cable, a modem re-attaching) could cost the whole SRT session.

Changes

  • The first 4 reconnect attempts of an established link run 1 s apart, on the housekeeping cadence C srtla_send uses. After that, the link retries every 5 s.
  • Only REG3 resets the attempt count. rebuild_uplink_socket used to reset it after every successful bind. That meant the count only climbed when the bind failed. A link with a dead path and a live interface retried at a flat 5 s, and with reconnect: retry at housekeeping cadence before backing off (match C srtla_send) #18 applied it would have retried at 1 s forever.
  • The exponential ladder (5 s doubling to 120 s) is gone. With the count fixed, the ladder would climb for real, and a link that recovers after a few minutes would wait up to 2 minutes more. A flat 5 s matches what production has done in practice.
  • Retries allow half a tick of slack. Each attempt is stamped when its housekeeping tick is serviced. With a strict >= 1000 check, a tick that ran a few ms late pushed the retry a whole second later. Initial registration had the same edge and gets the same slack.
  • No new flags, TOML keys or JSON-RPC methods. With a 1000 ms floor and a 1 s tick, the ms knob in reconnect: retry at housekeeping cadence before backing off (match C srtla_send) #18 could only take the values 1 to 5 s, and nobody asked for the attempt count to be tunable.
  • AGENTS.md "Robustness Behaviors" records the pacing policy. The README documents --conn-timeout-ms and the retry pacing.

Review notes

  • Start with crates/srtla-core/src/connection/reconnection.rs, then the one-line removals in src/sender/connections.rs and connection/mod.rs.
  • The re-home path also goes through rebuild_uplink_socket. After a re-home, links keep their attempt count and retry every 5 s. That matches their pacing before this change.
  • Two housekeeping tests used a 120 s backoff to keep per-link reconnects out of the test window. They now stamp the last attempt past the window instead.
  • The netns integration tests need network namespaces and were not run.

Summary by CodeRabbit

  • New Features
    • Links that time out now retry registration once per second for the first four attempts, then every five seconds until registration succeeds. Successful registration restores the faster retry cadence.
    • Receiver DNS changes detected during a reconnect are reported while the current connection address is retained.
  • Documentation
    • Clarified that the connection timeout defaults to 5 seconds, can be set from 1 to 60 seconds, and can be changed at runtime. Silence beyond the timeout triggers link reconnection.

SRT drops the session after 5 s of silence, so the first retry of an
established link came too late for a sub-second blip (bumped USB cable,
modem re-attach). The first 4 attempts now run 1 s apart, matching the
C sender's housekeeping cadence, then every 5 s.

A successful socket rebuild reset the attempt count, so the backoff
ladder never climbed while the local bind worked and a dead path
retried at a flat 5 s. Only REG3 resets the count now. The ladder is
gone: with a working count it would leave a link that recovers after a
few minutes waiting up to 2 minutes more.

Retries allow half a tick of slack. Each attempt is stamped when its
tick was serviced, so a strict 1000 ms check missed by a few ms whenever
one tick ran late, and the retry slipped a whole tick.

Co-authored-by: Simon <simonaverhoeven@gmail.com>
@datagutt
datagutt merged commit 8828370 into main Sep 24, 2026
6 checks passed
@datagutt
datagutt deleted the fix/fast-reconnect-retry branch September 24, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant