Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Librespot mDNS-related error on machine startup #1404

Open
hamiltron opened this issue Nov 24, 2024 · 3 comments
Open

Librespot mDNS-related error on machine startup #1404

hamiltron opened this issue Nov 24, 2024 · 3 comments
Labels

Comments

@hamiltron
Copy link

Description

Librespot appears to be throwing an mDNS-related error on machine startup when run as a systemd service. This doesn't kill the service, but leaves mDNS broken (so it's not visible in the Spotify app as a playback device).

If I restart the service after startup there is no error, and if I add a 30 sec delay (using ExecStartPre=/bin/sleep 30 in the service file), it also starts up without an issue.

I'm wondering if there's another service dependency that needs to be added to the service file. Or is it possible to have librespot internally retry whatever failed?

Version

0.6.0 - built using cargo install librespot

Host:

  • OS: Ubuntu Server
  • Platform: 2014 Mac Mini

Systemd service file

[Unit]
Description=Librespot (an open source Spotify client)
Documentation=https://github.com/librespot-org/librespot
Documentation=https://github.com/librespot-org/librespot/wiki/Options
Wants=network.target sound.target
After=network.target sound.target

[Service]
DynamicUser=yes
SupplementaryGroups=audio
Restart=always
RestartSec=10
ExecStart=/usr/bin/librespot --name "Living Room" --bitrate 320 --device-type speaker --volume-range 30

[Install]
WantedBy=multi-user.target

Log

From journalctl -u librespot.service:

Nov 24 20:54:11 spotifyconnect systemd[1]: Started librespot.service - Librespot (an open source Spotify client).
Nov 24 20:54:11 spotifyconnect librespot[804]: [2024-11-24T20:54:11Z INFO  librespot] librespot 0.6.0 VERGEN_IDEMPOTENT_OUTPUT (Built on 2024-11-24, Build ID: 6jiAyOYl, Profile: release)
Nov 24 20:54:11 spotifyconnect librespot[804]: [2024-11-24T20:54:11Z INFO  librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Log(30.0)
Nov 24 20:54:11 spotifyconnect librespot[804]: thread 'tokio-runtime-worker' panicked at /home/sconnect/.cargo/registry/src/index.crates.io-6f17d22bba15001f/librespot-discovery-0.6.0/src/lib.rs:4>
Nov 24 20:54:11 spotifyconnect librespot[804]: called `Result::unwrap()` on an `Err` value: DnsSdError(Os { code: 19, kind: Uncategorized, message: "No such device" })
Nov 24 20:54:11 spotifyconnect librespot[804]: stack backtrace:
Nov 24 20:54:11 spotifyconnect librespot[804]: [2024-11-24T20:54:11Z INFO  librespot_playback::convert] Converting with ditherer: tpdf
Nov 24 20:54:11 spotifyconnect librespot[804]: [2024-11-24T20:54:11Z INFO  librespot_playback::audio_backend::rodio] Using Rodio sink with format S16 and cpal host: ALSA
Nov 24 20:54:11 spotifyconnect librespot[804]: [2024-11-24T20:54:11Z INFO  librespot_playback::audio_backend::rodio] Using audio device: default
Nov 24 20:54:11 spotifyconnect librespot[804]:    0:     0x595e7e2e7e3b - std::backtrace_rs::backtrace::libunwind::trace::he991e66e5f22a1db
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
Nov 24 20:54:11 spotifyconnect librespot[804]:    1:     0x595e7e2e7e3b - std::backtrace_rs::backtrace::trace_unsynchronized::h43f35a5576eecb13
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
Nov 24 20:54:11 spotifyconnect librespot[804]:    2:     0x595e7e2e7e3b - std::sys_common::backtrace::_print_fmt::hf9c799a68b2477fc
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:67:5
Nov 24 20:54:11 spotifyconnect librespot[804]:    3:     0x595e7e2e7e3b - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf2d48dfeb5948660
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:44:22
Nov 24 20:54:11 spotifyconnect librespot[804]:    4:     0x595e7e32cb70 - core::fmt::rt::Argument::fmt::h507ca91fbb1ef494
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/fmt/rt.rs:142:9
Nov 24 20:54:11 spotifyconnect librespot[804]:    5:     0x595e7e32cb70 - core::fmt::write::h4d5f6025aa566322
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/fmt/mod.rs:1120:17
Nov 24 20:54:11 spotifyconnect librespot[804]:    6:     0x595e7e2dafed - std::io::Write::write_fmt::hc088b3c8cc6dcb9f
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/io/mod.rs:1762:15
Nov 24 20:54:11 spotifyconnect librespot[804]:    7:     0x595e7e2e7c24 - std::sys_common::backtrace::_print::h231201f6cff8f56a
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:47:5
Nov 24 20:54:11 spotifyconnect librespot[804]:    8:     0x595e7e2e7c24 - std::sys_common::backtrace::print::h478d6be486f8cd2d
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:34:9
Nov 24 20:54:11 spotifyconnect librespot[804]:    9:     0x595e7e30fe1a - std::panicking::default_hook::{{closure}}::hf1c55106b4d45a90
Nov 24 20:54:11 spotifyconnect librespot[804]:   10:     0x595e7e30fabd - std::panicking::default_hook::h7b29000c631cc719
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:292:9
Nov 24 20:54:11 spotifyconnect librespot[804]:   11:     0x595e7e310238 - std::panicking::rust_panic_with_hook::h2a988919dd121561
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:779:13
Nov 24 20:54:11 spotifyconnect librespot[804]:   12:     0x595e7e2e821e - std::panicking::begin_panic_handler::{{closure}}::h3a9eaa1d23ecf555
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:657:13
Nov 24 20:54:11 spotifyconnect librespot[804]:   13:     0x595e7e2e8056 - std::sys_common::backtrace::__rust_end_short_backtrace::h813561fdec15f700
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:170:18
Nov 24 20:54:11 spotifyconnect librespot[804]:   14:     0x595e7e30ff62 - rust_begin_unwind
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:645:5
Nov 24 20:54:11 spotifyconnect librespot[804]:   15:     0x595e7d985785 - core::panicking::panic_fmt::hef0307862026e6f9
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/panicking.rs:72:14
Nov 24 20:54:11 spotifyconnect librespot[804]:   16:     0x595e7d985f33 - core::result::unwrap_failed::h8393ef8d489acb45
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/result.rs:1653:5
Nov 24 20:54:11 spotifyconnect librespot[804]:   17:     0x595e7dac764c - <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll::hb6ff2bf44a46c24f
Nov 24 20:54:11 spotifyconnect librespot[804]:   18:     0x595e7dab7296 - tokio::runtime::task::core::Core<T,S>::poll::h86bc5f204edfc32b
Nov 24 20:54:11 spotifyconnect librespot[804]:   19:     0x595e7dad05a7 - tokio::runtime::task::harness::Harness<T,S>::poll::he45923982f554afd
Nov 24 20:54:11 spotifyconnect librespot[804]:   20:     0x595e7e20017e - tokio::runtime::blocking::pool::Inner::run::h6bea6cc4f7efd364
Nov 24 20:54:11 spotifyconnect librespot[804]:   21:     0x595e7e1fb4d7 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5318546ef6af7a8b
Nov 24 20:54:11 spotifyconnect librespot[804]:   22:     0x595e7e1fbfb9 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h1c791331d92e823d
Nov 24 20:54:11 spotifyconnect librespot[804]:   23:     0x595e7e2dd845 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hebd3f136d7c70a48
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/alloc/src/boxed.rs:2007:9
Nov 24 20:54:11 spotifyconnect librespot[804]:   24:     0x595e7e2dd845 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h813dea9db89ee3a5
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/alloc/src/boxed.rs:2007:9
Nov 24 20:54:11 spotifyconnect librespot[804]:   25:     0x595e7e2dd845 - std::sys::unix::thread::Thread::new::thread_start::h87ab7be5c1477cc7
Nov 24 20:54:11 spotifyconnect librespot[804]:                                at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys/unix/thread.rs:108:17
Nov 24 20:54:11 spotifyconnect librespot[804]:   26:     0x7ff22b09ca94 - <unknown>
Nov 24 20:54:11 spotifyconnect librespot[804]:   27:     0x7ff22b129c3c - <unknown>
Nov 24 20:54:11 spotifyconnect librespot[804]:   28:                0x0 - <unknown>
@hamiltron hamiltron added the bug label Nov 24, 2024
@wisp3rwind
Copy link
Contributor

Just to be sure: This is cargo install librespot with default features?

@hamiltron
Copy link
Author

hamiltron commented Nov 25, 2024

As far as I know, yes. I didn't add any additional parameters to the command. (Sorry, I'm not familiar with the Rust toolchain.) When I'd run that command, it seemed to do a full compile every time. It failed a few times until I'd installed the pkg-config and libasound2-dev packages, then it succeeded. From there I had to copy the binary to /usr/bin.

Also I forgot to mention the Ubuntu version is 24.04.

@wisp3rwind
Copy link
Contributor

Ok, then this should be using the libmdns zeroconf backend.

This seems to be the same as librespot-org/libmdns#50, i.e. some kind of network-not-yet-available issue. Someone would need to investigate what exactly is going on here... Similar to spotifyd, we might also implement a retry feature.

What kind of system are you running this on? If it has an MDNS responder running (e.g. Avahi on Linux), you could try building with one of the other zerconf backends, see also https://github.com/librespot-org/librespot/blob/dev/COMPILING.md#zeroconf-library-dependencies
For example

# Linux only, no additional dependencies, needs Avahi to be running
cargo build --features with-avahi librespot

or

# Should work on more systems, requires dns_sd to be available
cargo build --features with-dns-sd librespot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants