-
Notifications
You must be signed in to change notification settings - Fork 458
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
ConnectionReset - Spotifyd stops playing #706
Comments
Hello, I'm setting up spotifyd for the first time and thought I finally had it working, but I started running into this same issue. It seems that spotifyd will die and be set up again by systemd, but I have to close spotify-tui, re-open it, then restart a playlist for it to reconnect everything and play music. This is happening before the first song finishes so is a bit unusable. I had seen in a couple places this happens but one of the fixes was to get the systemd aspect set up for it to reconnect itself. However for me it's like I have a zombie daemon I need to completely get away from first.
I'll mention this in case it's related, one of my other problems setting up was I wanted and thought I was supposed to use Love this project if I can get this working to replace the official client that doesnt work with my vpn, and gets me one step closer to everything being a terminal app. |
I am here because I keep having to do
|
i have this issue sometimes as well, it happens for me when there is a short downtime in internet connectivity. |
After playing with it some more, I found that having my VPN on is what causes it to fail. I'm using NordVPN, and the official spotify client always says I'm offline, which sent me to find a different solution. Turns out spotifyd will lose connection when it is on, so I still have to turn the VPN off to play music normally. Not sure if that a problem with spotifyd, or because Spotify doesn't officially support VPN's (which kills me, how does a massive company with millions to throw at a podcast, not care about user security?). I'll still be using spotifyd with spotify-tui moving forward but I wish playing music didn't mean I had to sacrifice my security. |
@arburty i think we delegate that to librespot maybe they have similar issues as well. Ive seem more issues about vpn ill link them if i find them |
I think I'm running into a similar issues to this, where on some network change (VPN connect/disconnect, WiFi drops briefly) the daemon is no longer reachable from a Spotify client, but systemd still reports it's running. One possible fix may be to add a healthcheck that queries Spotify every X seconds (configurable?) to see if the daemon is among the reported devices, else exit and let systemd/launchd restart it. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Please don't stale this. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I am also having the same issue with NordVPN. It will randomly restart the spotifyd service anywhere between 1 - 5 minutes without any error messages so assuming its a connection drop. Turning off nordvpn resolves the issue. I can't seem to find any settings in the linux nordvpn to possibly not secure the spotifyd connection so not sure what to do. |
I am also having the same issue |
I'm considering writing a monitor systemd service just to monitor and restart. Otherwise spotifyd only works a small percentage of the time on one of my devices (maybe it's wired?) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Please do not stale this issue. @JojiiOfficial occasional reminder 🙂 |
librespot-org/librespot#427 seems to have corrected the root cause. Now I think spotifyd just needs some changes. |
I am still seeing this issue when using spotifyd:
This was after several hours of uninterrupted play. I also tried adding a simple script to occasionally skip a track as a 'keep alive' event which did not help either. That script is below, for reference:
I have this running on a Raspberry Pi model 4, with ubuntu
this seems to be related to: |
Same issue on manjaro linux. |
@stevensonmt Thanks for pointing that out... for some reason it is redirecting wrong, updated link: |
Experiencing the exact same issue on Arch Linux with NordVPN. I have to use |
Have exact same issue on Manjaro without using VPN.
|
Could you elaborate on what changes you have in mind? Spotifyd incorporates that patch and I'm still seeing this issue sometimes (particularly with group sessions). |
I'm experiencing this issue too, but with no VPN just a standard wifi network connection. It happens regardless of whether I run spotifyd from the cli or via systemd.
spotifyd doesn't quit, but music stops playing from spotify-tui and I can no longer connect to spotifyd as a device when I restart spotify-tui. Killing and restarting spotifyd solves the problem, but is annoying. Ubuntu 22.10 |
I am using spotifyd 0.3.5 and have the same problem when using NordVPN. The connection drops around 1 minute +- a few seconds. Here are the last three log lines after starting the song. They show up a few seconds after the song was started (I shortened the track and file ID):
Then there is no log output while it is playing. Once the problem appears (connection logst / song stops playing), this is the output:
And then it continues with authenticating a new session ... i can start another song without restarting spotifyd. |
Also nordvpn user with same problem here. Managed to somewhat override the problem by whitelisting certain subnets in nordvpn
Constant:
Dynamic:
So in my case whole list:
No problems ever since. |
This worked for me, thank you very much.
|
Mullvad user here I just used tinyproxy on a host without VPN and the |
I have the same issue even though I do not have any VPN running. I decided to install the dev version librespot hoping that it would fix the issue (it did not). It seems however that it is now fixed in the librespot dev version: see this thread https://github.com/librespot-org/librespot/issues/1340 and this PR https://github.com/librespot-org/librespot/pull/1357 I can confirm it works great now but I would love spotifyd to have the same fix (my own setup heavily relies on the dbus features in spotifyd). Is there a possibility to compile spotifyd using the newest Dev branch of Librespot, or will I need to wait for a new version release? |
You would need to edit librespot-core = { git = "https://github.com/wisp3rwind/librespot", branch = "pingpong" }
librespot-playback = { git = "https://github.com/wisp3rwind/librespot", branch = "pingpong", default-features = false }
librespot-audio = { git = "https://github.com/wisp3rwind/librespot", branch = "pingpong", default-features = false }
librespot-discovery = { git = "https://github.com/wisp3rwind/librespot", branch = "pingpong" }
librespot-connect = { git = "https://github.com/wisp3rwind/librespot", branch = "pingpong" } But it fails to build, it seems like there are some changes in a couple of interfaces: Build Logbuild-container-1 | Compiling librespot-audio v0.5.0-dev (https://github.com/wisp3rwind/librespot?branch=pingpong#1ca4ea56)
build-container-1 | Compiling librespot-metadata v0.5.0-dev (https://github.com/wisp3rwind/librespot?branch=pingpong#1ca4ea56)
build-container-1 | Compiling librespot-discovery v0.5.0-dev (https://github.com/wisp3rwind/librespot?branch=pingpong#1ca4ea56)
build-container-1 | Compiling librespot-playback v0.5.0-dev (https://github.com/wisp3rwind/librespot?branch=pingpong#1ca4ea56)
build-container-1 | Compiling librespot-connect v0.5.0-dev (https://github.com/wisp3rwind/librespot?branch=pingpong#1ca4ea56)
build-container-1 | Compiling spotifyd v0.3.5 (/spotifyd)
build-container-1 | error[E0432]: unresolved import `librespot_core::config::ConnectConfig`
build-container-1 | --> src/main_loop.rs:15:14
build-container-1 | |
build-container-1 | 15 | config::{ConnectConfig, DeviceType, SessionConfig},
build-container-1 | | ^^^^^^^^^^^^^ no `ConnectConfig` in `config`
build-container-1 | |
build-container-1 | = help: consider importing this struct instead:
build-container-1 | librespot_connect::config::ConnectConfig
build-container-1 |
build-container-1 | error[E0061]: this function takes 3 arguments but 4 arguments were supplied
build-container-1 | --> src/main_loop.rs:99:9
build-container-1 | |
build-container-1 | 99 | Session::connect(session_config, creds, cache, true)
build-container-1 | | ^^^^^^^^^^^^^^^^ -------------- ----- unexpected argument #3 of type `std::option::Option<Cache>`
build-container-1 | | |
build-container-1 | | expected `&Session`, found `SessionConfig`
build-container-1 | |
build-container-1 | note: method defined here
build-container-1 | --> /usr/local/cargo/git/checkouts/librespot-adf6961143c7daaa/1ca4ea5/core/src/session.rs:242:18
build-container-1 | |
build-container-1 | 242 | pub async fn connect(
build-container-1 | | ^^^^^^^
build-container-1 | help: remove the extra argument
build-container-1 | |
build-container-1 | 99 - Session::connect(session_config, creds, cache, true)
build-container-1 | 99 + Session::connect(/* &Session */, creds, true)
build-container-1 | |
build-container-1 |
build-container-1 | error[E0308]: mismatched types
build-container-1 | --> src/main_loop.rs:101:19
build-container-1 | |
build-container-1 | 101 | .map(|(session, _creds)| session)
build-container-1 | | ^^^^^^^^^^^^^^^^^
build-container-1 | | |
build-container-1 | | expected `()`, found `(_, _)`
build-container-1 | | expected due to this
build-container-1 | |
build-container-1 | = note: expected unit type `()`
build-container-1 | found tuple `(_, _)`
build-container-1 |
build-container-1 | error[E0308]: mismatched types
build-container-1 | --> src/main_loop.rs:129:17
build-container-1 | |
build-container-1 | 129 | let (player, mut event_channel) = Player::new(
build-container-1 | | _________________^^^^^^^^^^^^^^^^^^^^^^^^^^^___-
build-container-1 | | | |
build-container-1 | | | expected `Arc<Player>`, found `(_, _)`
build-container-1 | 130 | | self.player_config.clone(),
build-container-1 | 131 | | session.clone(),
build-container-1 | 132 | | mixer.get_soft_volume(),
build-container-1 | 133 | | move || (backend)(audio_device, audio_format),
build-container-1 | 134 | | );
build-container-1 | | |_____________- this expression has type `Arc<Player>`
build-container-1 | |
build-container-1 | = note: expected struct `Arc<Player>`
build-container-1 | found tuple `(_, _)`
build-container-1 |
build-container-1 | error[E0061]: this function takes 5 arguments but 4 arguments were supplied
build-container-1 | --> src/main_loop.rs:136:39
build-container-1 | |
build-container-1 | 136 | let (spirc, spirc_task) = Spirc::new(
build-container-1 | | _______________________________________^^^^^^^^^^-
build-container-1 | 137 | | ConnectConfig {
build-container-1 | 138 | | autoplay: self.autoplay,
build-container-1 | 139 | | name: self.spotifyd_state.device_name.clone(),
build-container-1 | ... |
build-container-1 | 146 | | mixer,
build-container-1 | 147 | | );
build-container-1 | | |_____________- argument #5 of type `Arc<(dyn librespot_playback::mixer::Mixer + 'static)>` is missing
build-container-1 | |
build-container-1 | note: expected `Arc<Player>`, found `Box<dyn Mixer>`
build-container-1 | --> src/main_loop.rs:146:17
build-container-1 | |
build-container-1 | 146 | mixer,
build-container-1 | | ^^^^^
build-container-1 | = note: expected struct `Arc<Player>`
build-container-1 | found struct `Box<dyn librespot_playback::mixer::Mixer>`
build-container-1 | note: associated function defined here
build-container-1 | --> /usr/local/cargo/git/checkouts/librespot-adf6961143c7daaa/1ca4ea5/connect/src/spirc.rs:271:18
build-container-1 | |
build-container-1 | 271 | pub async fn new(
build-container-1 | | ^^^
build-container-1 | help: provide the argument
build-container-1 | |
build-container-1 | 136 ~ let (spirc, spirc_task) = Spirc::new(ConnectConfig {
build-container-1 | 137 + autoplay: self.autoplay,
build-container-1 | 138 + name: self.spotifyd_state.device_name.clone(),
build-container-1 | 139 + device_type: self.device_type,
build-container-1 | 140 + initial_volume: self.initial_volume,
build-container-1 | 141 + has_volume_ctrl: self.has_volume_ctrl,
build-container-1 | 142 ~ }, session.clone(), player, /* Arc<Player> */, /* Arc<(dyn librespot_playback::mixer::Mixer + 'static)> */);
build-container-1 | |
build-container-1 |
build-container-1 | error[E0308]: mismatched types
build-container-1 | --> src/main_loop.rs:136:17
build-container-1 | |
build-container-1 | 136 | let (spirc, spirc_task) = Spirc::new(
build-container-1 | | _________________^^^^^^^^^^^^^^^^^^^___-
build-container-1 | | | |
build-container-1 | | | expected future, found `(_, _)`
build-container-1 | 137 | | ConnectConfig {
build-container-1 | 138 | | autoplay: self.autoplay,
build-container-1 | 139 | | name: self.spotifyd_state.device_name.clone(),
build-container-1 | ... |
build-container-1 | 146 | | mixer,
build-container-1 | 147 | | );
build-container-1 | | |_____________- this expression has type `impl futures::Future<Output = std::result::Result<(Spirc, impl futures::Future<Output = ()>), librespot_core::Error>>`
build-container-1 | |
build-container-1 | = note: expected opaque type `impl futures::Future<Output = std::result::Result<(Spirc, impl futures::Future<Output = ()>), librespot_core::Error>>`
build-container-1 | found tuple `(_, _)`
build-container-1 |
build-container-1 | error[E0560]: struct `SessionConfig` has no field named `user_agent`
build-container-1 | --> src/config.rs:876:13
build-container-1 | |
build-container-1 | 876 | user_agent: version::VERSION_STRING.to_string(),
build-container-1 | | ^^^^^^^^^^ `SessionConfig` does not have this field
build-container-1 | |
build-container-1 | = note: available fields are: `client_id`, `tmp_dir`, `autoplay`
build-container-1 |
build-container-1 | error[E0599]: no variant named `Changed` found for enum `PlayerEvent`
build-container-1 | --> src/process.rs:57:22
build-container-1 | |
build-container-1 | 57 | PlayerEvent::Changed {
build-container-1 | | ^^^^^^^ variant not found in `PlayerEvent`
build-container-1 |
build-container-1 | error[E0599]: no variant named `Started` found for enum `PlayerEvent`
build-container-1 | --> src/process.rs:65:22
build-container-1 | |
build-container-1 | 65 | PlayerEvent::Started {
build-container-1 | | ^^^^^^^ variant not found in `PlayerEvent`
build-container-1 |
build-container-1 | error[E0026]: variant `Playing` does not have a field named `duration_ms`
build-container-1 | --> src/process.rs:97:13
build-container-1 | |
build-container-1 | 97 | duration_ms,
build-container-1 | | ^^^^^^^^^^^ variant `Playing` does not have this field
build-container-1 |
build-container-1 | error[E0026]: variant `librespot_playback::player::PlayerEvent::Paused` does not have a field named `duration_ms`
build-container-1 | --> src/process.rs:109:13
build-container-1 | |
build-container-1 | 109 | duration_ms,
build-container-1 | | ^^^^^^^^^^^ variant `librespot_playback::player::PlayerEvent::Paused` does not have this field
build-container-1 |
build-container-1 | error[E0599]: no variant named `VolumeSet` found for enum `PlayerEvent`
build-container-1 | --> src/process.rs:133:22
build-container-1 | |
build-container-1 | 133 | PlayerEvent::VolumeSet { volume } => {
build-container-1 | | ^^^^^^^^^ variant not found in `PlayerEvent`
build-container-1 |
build-container-1 | error[E0061]: this function takes 2 arguments but 1 argument was supplied
build-container-1 | --> src/setup.rs:103:23
build-container-1 | |
build-container-1 | 103 | match librespot_discovery::Discovery::builder(session_config.device_id.clone())
build-container-1 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------- argument #2 of type `std::string::String` is missing
build-container-1 | |
build-container-1 | note: associated function defined here
build-container-1 | --> /usr/local/cargo/git/checkouts/librespot-adf6961143c7daaa/1ca4ea5/discovery/src/lib.rs:174:12
build-container-1 | |
build-container-1 | 174 | pub fn builder<T: Into<String>>(device_id: T, client_id: T) -> Builder {
build-container-1 | | ^^^^^^^
build-container-1 | help: provide the argument
build-container-1 | |
build-container-1 | 103 | match librespot_discovery::Discovery::builder(session_config.device_id.clone(), /* std::string::String */)
build-container-1 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
build-container-1 |
build-container-1 | error[E0308]: mismatched types
build-container-1 | --> src/setup.rs:158:38
build-container-1 | |
build-container-1 | 158 | if username.as_ref() == Some(&credentials.username) {
build-container-1 | | ---- ^^^^^^^^^^^^^^^^^^^^^ expected `&String`, found `&Option<String>`
build-container-1 | | |
build-container-1 | | arguments to this enum variant are incorrect
build-container-1 | |
build-container-1 | = note: expected reference `&std::string::String`
build-container-1 | found reference `&std::option::Option<std::string::String>`
build-container-1 | help: the type constructed contains `&std::option::Option<std::string::String>` due to the type of the argument passed
build-container-1 | --> src/setup.rs:158:33
build-container-1 | |
build-container-1 | 158 | if username.as_ref() == Some(&credentials.username) {
build-container-1 | | ^^^^^---------------------^
build-container-1 | | |
build-container-1 | | this argument influences the type of `Some`
build-container-1 | note: tuple variant defined here
build-container-1 | --> /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/option.rs:582:5
build-container-1 |
build-container-1 | Some errors have detailed explanations: E0026, E0061, E0308, E0432, E0560, E0599.
build-container-1 | For more information about an error, try `rustc --explain E0026`.
build-container-1 | error: could not compile `spotifyd` (bin "spotifyd") due to 14 previous errors
build-container-1 exited with code 101 If you want to try to debug / fix it yourself:
Change the Run or use services:
build-container:
image: rust:1-bookworm
# platform: linux/arm64 # (Optional)
command: bash -c "
apt-get update &&
apt-get install -y \
libasound2-dev \
libssl-dev \
pkg-config &&
cargo build --release"
working_dir: /spotifyd
volumes:
- ./:/spotifyd |
Yeah afraid the spotifyd compiling would be broken using the dev branch. Resolving the issues described are a bit above my own competence when it comes to debugging. I suppose I will have to waiting for librespot to release v0.5 and spotifyd to implement it. |
It seems that librespot v0.5.0 has been released with the fix |
if anyone needs a workaround, my current solution to this was to create a service that watches the spotifyd logs and restarts it when "Connection reset by peer (os error 104)" is thrown. The following was tested on Debian bookworm:
|
I've been having this issue for a while, so I'm willing to test it. However, I tried to follow the setup for cross-compiling to armhf on Ubuntu (not docker), but could not get it to compile. |
You'll need rust 1.81 or higher, services:
build-container:
image: rust:bookworm
platform: linux/arm64
command: bash -c "
apt-get update &&
apt-get install -y \
libasound2-dev \
libssl-dev \
pkg-config &&
curl -sSL https://github.com/eladyn/spotifyd/archive/refs/heads/deps_upgrade.tar.gz | tar xz -C /spotifyd --strip-components=1 &&
cargo build --release &&
cp /spotifyd/target/release/spotifyd /build/"
working_dir: /spotifyd
volumes:
- ./:/build
|
Thanks for the info, I managed to cross-compile to arm64 (armhf also failed using docker). But then I had to reinstall the OS on the raspberry pi to accommodate. After running for about 2 days I can say that this update definitely solves any issues I had with connection being reset, it's playing for hours without any problems whatsoever. |
Description
Random reset stops songs from playing, and player disappears from Spotify. Spotify daemon is still running (active) but can't select player / play more songs without service stop/start.
To Reproduce
Expected behaviour is that the daemon/service would stay active & connected for days/weeks.
Logs
Click to show logs
Nov 03 16:08:22 (name) spotifyd[2192]: Os { code: 104, kind: ConnectionReset, message: "Connection reset by peer" }Compilation flags
Using pre-built binary
Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: