srt: optional server silence timeout to detect a dead path - #2194
Merged
pedroSG94 merged 1 commit intoSep 11, 2026
Merged
Conversation
SrtSender does not wait for ACKs and handleServerPackets swallows receive
timeouts, so a silent path (NAT rebind, black hole, frozen server) is never
reported: the stream keeps sending into the void. setServerSilenceTimeout(ms)
reports onConnectionFailed("No response from server") when no packet from
the server arrived for the given time. Disabled by default (0).
Owner
|
Hello, Thank you for the fix. Merged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SRT: optional server silence timeout
Motivation
When the network path dies silently, the SRT client keeps sending and never reports a failure. Examples: a tunnel, a dead zone where the interface stays up, NAT rebinding, or UDP silently dropped by a middlebox. UDP
senddoes not fail,SrtSenderdoes not wait for ACKs, andhandleServerPacketstreats everySocketTimeoutExceptionasConnectionFailed.TIMEOUT. The app therefore streams into the void until the server-side session is dropped. We measured more than 60 s with MediaMTX.setCheckServerAlive(true)does not help in our setup. It relies onisReachable()(ICMP/Echo), which is blocked by most cloud firewalls (e.g. Azure), so it reports healthy connections as dead.Change
SrtClient.setServerSilenceTimeout(millis), exposed asSrtStreamClient.setServerSilenceTimeout(millis). The default is0, which disables it, so existing behavior does not change.handleServerPacketsremembers when the last packet (ACK, keepalive, NAK, …) arrived from the server. If a read times out and nothing has been received for at leastmillis, it reportsonConnectionFailed("No response from server")and cancels the scope. That is the same path the existingcheckServerAlivebranch uses, soreTryworks as usual.millisandmillis + 5 s.Testing
Android emulator publishing to MediaMTX 1.18.2 over SRT.
docker pauseon the MediaMTX container for 60 s simulates a silent dead path (no reply, no ICMP).setServerSilenceTimeout(10_000)onConnectionFailed("No response from server")11 s after the pause started;reTrythen attempts roughly every 7 s (handshake timeout)handleServerPacketsis private and the client creates its socket internally, so a unit test would need a socket-injection refactor. Verified end-to-end instead.