Retry UDP request on timeout before giving up#7
Open
mcfnord wants to merge 1 commit intosoftins:masterfrom
Open
Retry UDP request on timeout before giving up#7mcfnord wants to merge 1 commit intosoftins:masterfrom
mcfnord wants to merge 1 commit intosoftins:masterfrom
Conversation
Replace the single 1.5s socket timeout with a 500ms timeout and up to 3 attempts. If no data is received within the window, the same request is re-sent. This recovers from dropped UDP packets without increasing the worst-case wait time beyond the original 1.5s.
Author
|
I haven't run this in production. Will do so and report results here. |
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.
Summary
SO_RCVTIMEOwith a 500ms timeout and up to 3 attemptsrecvfromwaits againMotivation
UDP is inherently lossy. The original code made one attempt and either succeeded or silently returned nothing to the client. Under any packet loss — even transient — the directory or server query would fail completely. The retry loop makes the behaviour consistent with what users expect from a web page fetching live server lists.
Test plan
anygenre1.jamulus.io:22124is ~142ms, well within the 500ms windowiptables40% random UDP drop rule and ran 20 requests: attempt-2 recoveries worked correctly, attempt-3 recoveries worked correctly, total-failure rate matched expectedp³probability