Fall back to IPv4 when IPv6 dual-stack bind fails in discovery#1724
Open
stiefenm wants to merge 1 commit into
Open
Fall back to IPv4 when IPv6 dual-stack bind fails in discovery#1724stiefenm wants to merge 1 commit into
stiefenm wants to merge 1 commit into
Conversation
On systems where IPv6 is completely disabled at the kernel level (e.g. `ipv6.disable=1` on Raspberry Pi / piCorePlayer), the dual-stack bind to `[::]:port` fails with EAFNOSUPPORT (os error 97), preventing the discovery server from starting entirely. Fall back to binding `0.0.0.0:port` (IPv4-only) when the dual-stack bind fails on non-Windows systems. This preserves dual-stack behavior on normal systems while allowing discovery to work on IPv4-only hosts. Fixes librespot-org#1694
Author
|
CI clippy failure is a pre-existing issue in |
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
0.0.0.0:port(IPv4-only) when the[::]:port(IPv6 dual-stack) bind fails on non-Windows systemsOn systems where IPv6 is completely disabled at the kernel level (e.g.
ipv6.disable=1on Raspberry Pi / piCorePlayer),TcpListener::bind("[::]:port")fails withEAFNOSUPPORT(os error 97), preventing the discovery server from starting entirely. This makes librespot invisible to the Spotify app on those hosts.The fix tries the dual-stack bind first (preserving existing behavior on normal systems), and only falls back to IPv4 if it fails. The Windows path is unaffected (it already binds to
0.0.0.0).Tested
Running this patch in production via SpotOn (an LMS Spotify plugin using librespot) on both dual-stack and IPv4-only systems. Multiple users on piCorePlayer / Raspberry Pi have confirmed discovery works with
ipv6.disable=1after this change.Fixes #1694