Fix annoying 'refused connection' logs spamming dmesg due to spotify connect

This commit is contained in:
2026-03-01 12:33:53 -08:00
parent 2ed58e1ec5
commit e9e925eb46
4 changed files with 55 additions and 0 deletions

View File

@@ -86,6 +86,9 @@ in
services.gnome.gnome-keyring.enable = true;
security.pam.services.googlebot.enableGnomeKeyring = true;
# Spotify Connect discovery
networking.firewall.allowedTCPPorts = [ 57621 ];
# Mount personal SMB stores
services.mount-samba.enable = true;

View File

@@ -24,6 +24,10 @@
# Music assistant (must be exposed so local devices can fetch the audio stream from it)
8095
8097
# Music assistant: Spotify Connect zeroconf discovery (one per librespot instance)
44200
44201
];
services.zigbee2mqtt = {

View File

@@ -15,4 +15,12 @@ in
incus-lts = prev.incus-lts.overrideAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ prev.writableTmpDirAsHomeHook ];
});
# Add --zeroconf-port support to Spotify Connect plugin so librespot
# binds to a fixed port that can be opened in the firewall.
music-assistant = prev.music-assistant.overrideAttrs (old: {
patches = (old.patches or [ ]) ++ [
../patches/music-assistant-zeroconf-port.patch
];
});
}

View File

@@ -0,0 +1,40 @@
diff --git a/music_assistant/providers/spotify_connect/__init__.py b/music_assistant/providers/spotify_connect/__init__.py
index 1111111..2222222 100644
--- a/music_assistant/providers/spotify_connect/__init__.py
+++ b/music_assistant/providers/spotify_connect/__init__.py
@@ -51,6 +51,7 @@ CONNECT_ITEM_ID = "spotify_connect"
CONF_PUBLISH_NAME = "publish_name"
CONF_ALLOW_PLAYER_SWITCH = "allow_player_switch"
+CONF_ZEROCONF_PORT = "zeroconf_port"
# Special value for auto player selection
PLAYER_ID_AUTO = "__auto__"
@@ -117,6 +118,15 @@ async def get_config_entries(
description="How should this Spotify Connect device be named in the Spotify app?",
default_value="Music Assistant",
),
+ ConfigEntry(
+ key=CONF_ZEROCONF_PORT,
+ type=ConfigEntryType.INTEGER,
+ label="Zeroconf port",
+ description="Fixed TCP port for Spotify Connect discovery (zeroconf). "
+ "Set to a specific port and open it in your firewall to allow "
+ "devices on the network to discover this player. 0 = random port.",
+ default_value=0,
+ ),
# ConfigEntry(
# key=CONF_HANDOFF_MODE,
# type=ConfigEntryType.BOOLEAN,
@@ -677,6 +687,11 @@ class SpotifyConnectProvider(PluginProvider):
"--onevent",
str(EVENTS_SCRIPT),
"--emit-sink-events",
+ *(
+ ["--zeroconf-port", str(zeroconf_port)]
+ if (zeroconf_port := int(self.config.get_value(CONF_ZEROCONF_PORT) or 0)) > 0
+ else []
+ ),
]
self._librespot_proc = librespot = AsyncProcess(
args, stdout=False, stderr=True, name=f"librespot[{self.name}]", env=env