Skip to content

Try the next server on failure, and fall back when the lookup fails - #1591

Merged
frenck merged 1 commit into
mainfrom
frenck/server-selection
Oct 2, 2026
Merged

frenck merged 1 commit into
mainfrom
frenck/server-selection

Conversation

@frenck

@frenck frenck commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Breaking change

None for callers. When the DNS lookup of the API servers fails, the client now falls back to all.api.radio-browser.info instead of raising a RadioBrowserConnectionError, so requests that used to fail now go through.

Proposed change

Found while comparing with other Radio Browser clients, and with what the API documentation asks of clients: "randomize the list and choose the first entry", and "if a request fails just retry the request with the next entry in the list".

Moving on to the next server. The client used to look up the servers again on every retry and pick one at random, so a retry could land on the server that just failed. It now looks up the servers once, shuffles them, and moves on to the next one when a request fails. Only when every server has been tried, it looks them up again.

A fallback for the lookup. The servers are published as DNS SRV records, which some home routers and DNS filters do not handle well. When that lookup fails or comes back empty, the client now uses all.api.radio-browser.info, whose plain A and AAAA records point to all API servers, and which the server certificate covers. pyradios, radiobrowser4j and several other clients use that name as their main way to find the servers. A hard-coded list of servers would go stale: nl1, at1 and fi1 from older documentation no longer exist.

For the record: right now the API has a single server, de1, so moving on to the next server pays off once there are more again. The fallback helps today.

Checked live: the normal lookup picks de1, and with the SRV lookup made to fail, requests go to all.api.radio-browser.info and succeed.

Type of change

  • Dependency or tooling upgrade
  • Bugfix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Deprecation (replaces or removes a feature, with a migration path)
  • Breaking change (a fix or feature that changes existing behavior)
  • Code quality, refactor, or test-only change
  • Documentation only

Additional information

  • This PR fixes or closes issue: fixes # None
  • This PR is related to: None
  • Link to a separate documentation pull request: None

Checklist

  • I fully understand the code in this pull request and can explain every line, including any AI-assisted changes.
  • The change is covered by tests, and poetry run pytest passes locally. A pull request cannot be merged unless CI is green.
  • poetry run prek run --all-files passes (lint, format, and type checks).
  • No commented-out or dead code is left in the pull request.

Look up the API servers once, shuffled, and move on to the next one when
a request fails, as the API documentation asks. Fall back to
all.api.radio-browser.info when the SRV lookup fails or comes back empty.
@frenck frenck added the enhancement Enhancement of the code, not introducing new features. label Oct 2, 2026
@frenck
frenck merged commit 076eadc into main Oct 2, 2026
31 checks passed
@frenck
frenck deleted the frenck/server-selection branch October 2, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement of the code, not introducing new features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant