[GH-ISSUE #1313] Discovery server immediately shuts down after starting, no visible error #600

Closed
opened 2026-02-27 19:31:30 +03:00 by kerem · 1 comment
Owner

Originally created by @Pierric82 on GitHub (Aug 22, 2024).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/1313

Hi!

This may not be a bug, and may be a user problem... but I'm at a loss. I will follow the bug template to be as thorough as I can.

Describe the bug
I'm using librespot via raspotify. I was previously using authentication with username and password, but as discussed in another thread on this repo (which I am very thankful for as it finally confirmed what was happening), I need to switch to discovery via mDNS. Now, for context, I was never able to make this work in the past. But the error I'm getting now is different from what I saw in the past.

Basically, now, I see that librespot starts the discovery service successfully on a random port, then immediately shuts it down, with no further information (see logs below).
I've tried to follow through the code to see if anything would give me a hint, but even though I have basics in rust I'm not sure about the tokio select! structure used in discovery/src/server.rs. Line 309 seems to be the one, and to my naive reading it looks like we shut down immediately upon starting due to the way the async expression is used, but that must be incorrect, otherwise this wouldn't work for anybody. So bottom line, I don't understand the code :)

I run this on raspberry pi running raspberry pi OS 12. I have tried with both avahi-daemon started, and stopped, it doesn't change what I see. I will add that I never understood how something like librespot and avahi/mDNS are supposed to work together, which makes it even harder for me to understand the problem. If there is any useful resource on this I'd love to read it, I couldn't find anything at the right level of vulgarization for me.

To reproduce
Steps to reproduce the behavior:

  1. install and run raspotify on Raspberry Pi OS 12
  2. set up no credentials (commenting out the username, password, disable_discovery and disable_credentials_cache lines)
  3. start the raspotify service (which in turn will run librespot)

Log

Aug 22 13:54:26 pi4 systemd[1]: Started raspotify.service - Raspotify (Spotify Connect Client).
Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z INFO  librespot] librespot 0.4.2 a6e1258 (Built on 2023-06-21, Build ID: g9ifMDjd, Profile: release)
Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot] Environment variable(s):
Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot]                 LIBRESPOT_NAME="raspotify (pi4)"
Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot]                 LIBRESPOT_BACKEND="alsa"
Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot]                 LIBRESPOT_CACHE="/var/cache/raspotify"
Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot]                 LIBRESPOT_SYSTEM_CACHE="/var/lib/raspotify"
Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot]                 LIBRESPOT_AUTOPLAY=
Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot]                 LIBRESPOT_DISABLE_AUDIO_CACHE=
Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot]                 LIBRESPOT_ENABLE_VOLUME_NORMALISATION=
Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot]                 LIBRESPOT_VERBOSE=
Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot]                 LIBRESPOT_DEVICE="hdmi:CARD=vc4hdmi0"
Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z DEBUG librespot_discovery::server] Zeroconf server listening on 0.0.0.0:36309
Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z DEBUG librespot_discovery::server] Shutting down discovery server

Host (what you are running librespot on):

  • OS: Raspberry Pi OS 12
  • Platform: Raspberry Pi 4

Additional context
As mentioned I run this via raspotify, but I'm thinking the librespot project is a better place to ask this, as raspotify is just acting as a wrapper here. I hope the logs are enough to explain my setup, but I'm happy to share other things such as the raspotify config if it can be useful.

Thank you!

EDIT: I realised after writing this that raspotify is based on a fork of librespot, I didn't know this :( I compiled librespot from source and I'm not getting that problem yet. However I still can't see the device from a Spotify client.
This is what I now see when starting librespot:

[2024-08-22T17:35:07Z INFO  librespot] librespot 0.5.0-dev a3a1c17 (Built on 2024-08-22, Build ID: pfb1uwz3, Profile: release)
[2024-08-22T17:35:07Z TRACE librespot] Command line argument(s):
[2024-08-22T17:35:07Z TRACE librespot]          device "hdmi:CARD=vc4hdmi0,DEV=0"
[2024-08-22T17:35:07Z TRACE librespot]          disable-audio-cache
[2024-08-22T17:35:07Z TRACE librespot]          n "librespot"
[2024-08-22T17:35:07Z TRACE librespot]          verbose
[2024-08-22T17:35:07Z TRACE librespot]          i "0.0.0.0"
[2024-08-22T17:35:07Z DEBUG librespot_core::session] new Session
[2024-08-22T17:35:07Z DEBUG librespot_discovery::server] Zeroconf server listening on 0.0.0.0:38105
[2024-08-22T17:35:07Z INFO  librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Log(60.0)
[2024-08-22T17:35:07Z DEBUG librespot_playback::player] new Player [0]
[2024-08-22T17:35:07Z INFO  librespot_playback::convert] Converting with ditherer: tpdf
[2024-08-22T17:35:07Z INFO  librespot_playback::audio_backend::rodio] Using Rodio sink with format S16 and cpal host: ALSA
ALSA lib pcm_dmix.c:972:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_asym.c:105:(_snd_pcm_asym_open) capture slave is not defined
ALSA lib pcm_asym.c:105:(_snd_pcm_asym_open) capture slave is not defined
[2024-08-22T17:35:07Z INFO  librespot_playback::audio_backend::rodio] Using audio device: hdmi:CARD=vc4hdmi0,DEV=0
[2024-08-22T17:35:07Z DEBUG librespot_playback::audio_backend::rodio] Rodio sink was created
Originally created by @Pierric82 on GitHub (Aug 22, 2024). Original GitHub issue: https://github.com/librespot-org/librespot/issues/1313 Hi! This may not be a bug, and may be a user problem... but I'm at a loss. I will follow the bug template to be as thorough as I can. **Describe the bug** I'm using librespot via raspotify. I was previously using authentication with username and password, but as discussed in another thread on this repo (which I am very thankful for as it finally confirmed what was happening), I need to switch to discovery via mDNS. Now, for context, I was never able to make this work in the past. But the error I'm getting now is different from what I saw in the past. Basically, now, I see that librespot starts the discovery service successfully on a random port, then immediately shuts it down, with no further information (see logs below). I've tried to follow through the code to see if anything would give me a hint, but even though I have basics in rust I'm not sure about the tokio select! structure used in discovery/src/server.rs. Line 309 seems to be the one, and to my naive reading it looks like we shut down immediately upon starting due to the way the async expression is used, but that must be incorrect, otherwise this wouldn't work for anybody. So bottom line, I don't understand the code :) I run this on raspberry pi running raspberry pi OS 12. I have tried with both avahi-daemon started, and stopped, it doesn't change what I see. I will add that I never understood how something like librespot and avahi/mDNS are supposed to work together, which makes it even harder for me to understand the problem. If there is any useful resource on this I'd love to read it, I couldn't find anything at the right level of vulgarization for me. **To reproduce** Steps to reproduce the behavior: 1. install and run raspotify on Raspberry Pi OS 12 2. set up no credentials (commenting out the username, password, disable_discovery and disable_credentials_cache lines) 3. start the raspotify service (which in turn will run librespot) **Log** ``` Aug 22 13:54:26 pi4 systemd[1]: Started raspotify.service - Raspotify (Spotify Connect Client). Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z INFO librespot] librespot 0.4.2 a6e1258 (Built on 2023-06-21, Build ID: g9ifMDjd, Profile: release) Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot] Environment variable(s): Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot] LIBRESPOT_NAME="raspotify (pi4)" Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot] LIBRESPOT_BACKEND="alsa" Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot] LIBRESPOT_CACHE="/var/cache/raspotify" Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot] LIBRESPOT_SYSTEM_CACHE="/var/lib/raspotify" Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot] LIBRESPOT_AUTOPLAY= Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot] LIBRESPOT_DISABLE_AUDIO_CACHE= Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot] LIBRESPOT_ENABLE_VOLUME_NORMALISATION= Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot] LIBRESPOT_VERBOSE= Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z TRACE librespot] LIBRESPOT_DEVICE="hdmi:CARD=vc4hdmi0" Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z DEBUG librespot_discovery::server] Zeroconf server listening on 0.0.0.0:36309 Aug 22 13:54:26 pi4 librespot[396462]: [2024-08-22T11:54:26Z DEBUG librespot_discovery::server] Shutting down discovery server ``` **Host (what you are running `librespot` on):** - OS: Raspberry Pi OS 12 - Platform: Raspberry Pi 4 **Additional context** As mentioned I run this via raspotify, but I'm thinking the librespot project is a better place to ask this, as raspotify is just acting as a wrapper here. I hope the logs are enough to explain my setup, but I'm happy to share other things such as the raspotify config if it can be useful. Thank you! EDIT: I realised after writing this that raspotify is based on a *fork* of librespot, I didn't know this :( I compiled librespot from source and I'm not getting that problem *yet*. However I still can't see the device from a Spotify client. This is what I now see when starting librespot: ``` [2024-08-22T17:35:07Z INFO librespot] librespot 0.5.0-dev a3a1c17 (Built on 2024-08-22, Build ID: pfb1uwz3, Profile: release) [2024-08-22T17:35:07Z TRACE librespot] Command line argument(s): [2024-08-22T17:35:07Z TRACE librespot] device "hdmi:CARD=vc4hdmi0,DEV=0" [2024-08-22T17:35:07Z TRACE librespot] disable-audio-cache [2024-08-22T17:35:07Z TRACE librespot] n "librespot" [2024-08-22T17:35:07Z TRACE librespot] verbose [2024-08-22T17:35:07Z TRACE librespot] i "0.0.0.0" [2024-08-22T17:35:07Z DEBUG librespot_core::session] new Session [2024-08-22T17:35:07Z DEBUG librespot_discovery::server] Zeroconf server listening on 0.0.0.0:38105 [2024-08-22T17:35:07Z INFO librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Log(60.0) [2024-08-22T17:35:07Z DEBUG librespot_playback::player] new Player [0] [2024-08-22T17:35:07Z INFO librespot_playback::convert] Converting with ditherer: tpdf [2024-08-22T17:35:07Z INFO librespot_playback::audio_backend::rodio] Using Rodio sink with format S16 and cpal host: ALSA ALSA lib pcm_dmix.c:972:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ALSA lib pcm_asym.c:105:(_snd_pcm_asym_open) capture slave is not defined ALSA lib pcm_asym.c:105:(_snd_pcm_asym_open) capture slave is not defined [2024-08-22T17:35:07Z INFO librespot_playback::audio_backend::rodio] Using audio device: hdmi:CARD=vc4hdmi0,DEV=0 [2024-08-22T17:35:07Z DEBUG librespot_playback::audio_backend::rodio] Rodio sink was created ```
kerem 2026-02-27 19:31:30 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@Pierric82 commented on GitHub (Aug 23, 2024):

I found out about the discussions, and I suppose mine is a user/machine issue, so I will close this issue and open a new discussion with fresh info.

<!-- gh-comment-id:2306751111 --> @Pierric82 commented on GitHub (Aug 23, 2024): I found out about the discussions, and I suppose mine is a user/machine issue, so I will close this issue and open a new discussion with fresh info.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#600
No description provided.