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

ConnectionReset - Spotifyd stops playing #706

Open
1 of 6 tasks
SpotOfBother opened this issue Nov 3, 2020 · 36 comments
Open
1 of 6 tasks

ConnectionReset - Spotifyd stops playing #706

SpotOfBother opened this issue Nov 3, 2020 · 36 comments
Labels
bug A functionality or parts of a program that do not work as intended

Comments

@SpotOfBother
Copy link

SpotOfBother commented Nov 3, 2020

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

  • dbus_mpris
  • dbus_keyring
  • alsa_backend
  • portaudio_backend
  • pulseaudio_backend
  • rodio_backend
    Using pre-built binary

Versions (please complete the following information):

none
@SpotOfBother SpotOfBother added the bug A functionality or parts of a program that do not work as intended label Nov 3, 2020
@arburty
Copy link

arburty commented Nov 5, 2020

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.

Linux pop-os 5.8.0-7625-generic #26~1603389471~20.04~f6b125f-Ubuntu SMP Thu Oct 22 20:35:49 UTC x86_64 x86_64 x86_64 GNU/Linux Version: v0.2.24 spotifyd-linux-full

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 pulseaudio as the backend but it did not work and did not show up in --help. It finally worked when using alsa despite using PulseAudio for other things.

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.

@colemickens
Copy link

I am here because I keep having to do systemctl --user restart spotifyd to get it to reconnect. The last log before "hanging" (staying disconnected) is:

Nov 06 06:29:11 slynux spotifyd[2936]: Os { code: 104, kind: ConnectionReset, message: "Connection reset by peer" }

@robinvd
Copy link
Contributor

robinvd commented Nov 11, 2020

i have this issue sometimes as well, it happens for me when there is a short downtime in internet connectivity.

@arburty
Copy link

arburty commented Nov 11, 2020

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.

@robinvd
Copy link
Contributor

robinvd commented Nov 11, 2020

@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

@dvdmuckle
Copy link

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.

@stale
Copy link

stale bot commented Feb 27, 2021

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.

@stale stale bot added the wontfix Issues that will not be fixed under any circumstances label Feb 27, 2021
@JojiiOfficial JojiiOfficial removed the wontfix Issues that will not be fixed under any circumstances label Mar 1, 2021
@stale
Copy link

stale bot commented May 31, 2021

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.

@stale stale bot added the wontfix Issues that will not be fixed under any circumstances label May 31, 2021
@lf94
Copy link

lf94 commented May 31, 2021

Please don't stale this.

@stale stale bot removed the wontfix Issues that will not be fixed under any circumstances label May 31, 2021
@stale
Copy link

stale bot commented Aug 29, 2021

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.

@stale stale bot added the wontfix Issues that will not be fixed under any circumstances label Aug 29, 2021
@JojiiOfficial JojiiOfficial removed the wontfix Issues that will not be fixed under any circumstances label Aug 29, 2021
@kmatherne
Copy link

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.

@thomdabrowski
Copy link

I am also having the same issue

@colemickens
Copy link

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?)

@stale
Copy link

stale bot commented Dec 19, 2021

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.

@stale stale bot added the wontfix Issues that will not be fixed under any circumstances label Dec 19, 2021
@lf94
Copy link

lf94 commented Dec 20, 2021

Please do not stale this issue. @JojiiOfficial occasional reminder 🙂
Edit: The bot did it.

@stale stale bot removed the wontfix Issues that will not be fixed under any circumstances label Dec 20, 2021
@lf94
Copy link

lf94 commented Dec 20, 2021

librespot-org/librespot#427 seems to have corrected the root cause. Now I think spotifyd just needs some changes.

@emz229
Copy link

emz229 commented Feb 8, 2022

I am still seeing this issue when using spotifyd:

Feb 08 19:56:43 ubuntu spotifyd[1787]: Writing: 35
Feb 08 19:56:43 ubuntu spotifyd[1787]: Running "/root/songcounter.sh" using "/bin/bash" with environm>
Feb 08 19:57:03 ubuntu spotifyd[1787]: Writing: 36
Feb 08 19:57:03 ubuntu spotifyd[1787]: Running "/root/songcounter.sh" using "/bin/bash" with environm>
Feb 08 19:57:03 ubuntu spotifyd[1787]: subscription terminated
Feb 08 19:57:03 ubuntu spotifyd[1787]: Error from channel for data receiver for range 2698220 (+16384>
Feb 08 19:57:03 ubuntu spotifyd[1787]: Error from channel for data receiver for range 2714604 (+16384>
Feb 08 19:57:03 ubuntu spotifyd[1787]: Connection reset by peer (os error 104)
Feb 08 19:57:03 ubuntu spotifyd[1787]: Error from channel for data receiver for range 2730988 (+16384>
Feb 08 19:57:03 ubuntu systemd[1]: spotifyd.service: Succeeded.
ubuntu@ubuntu:~$ date
Tue Feb  8 20:43:30 UTC 2022

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:

#!/bin/bash
# Simple script to count song changes and
# skip a song once in a while to keep spotify
# server alive.

declare -i skipat=100
n=$(</root/count.txt)
m=$((n + 1))
echo Writing: $m
if [ "$m" -gt "$skipat" -o "$m" -eq "$skipat" ]
then
        echo 0 > /root/count.txt
        /usr/bin/spt pb -n
else
        echo $m > /root/count.txt
fi

I have this running on a Raspberry Pi model 4, with ubuntu

root@ubuntu:~# uname -a Linux ubuntu 5.4.0-1050-raspi #56-Ubuntu SMP PREEMPT Thu Jan 13 13:09:35 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

this seems to be related to:

https://github.com/librespot-org/librespot/discussions/609

@stevensonmt
Copy link

Same issue on manjaro linux.
@emz229 your link to the librespot discussion is broken.

@emz229
Copy link

emz229 commented Feb 16, 2022

@stevensonmt Thanks for pointing that out... for some reason it is redirecting wrong, updated link:
librespot-org/librespot#609

@botsunny
Copy link

Experiencing the exact same issue on Arch Linux with NordVPN. I have to use systemctl --user restart spotifyd.service every time I toggle VPN on and off. Unfortunately, even after restarting the service, Spotifyd only plays for around a minute under VPN before the player stops. I have to disconnect from VPN and restart the service to get it going again. The Spotify web player works as expected when I use it while connected to VPN.

@inyutin
Copy link

inyutin commented May 22, 2022

Have exact same issue on Manjaro without using VPN.
Logs:

мая 22 13:01:36 dmitry-20s40044rt systemd[1374]: Started A spotify playing daemon.
мая 22 13:01:36 dmitry-20s40044rt systemd[1374]: Stopped A spotify playing daemon.
мая 22 13:01:36 dmitry-20s40044rt systemd[1374]: spotifyd.service: Scheduled restart job, restart counter is at 1.
мая 22 13:01:24 dmitry-20s40044rt spotifyd[13705]: Error from channel for data receiver for range 987136 (+16384).
мая 22 13:01:24 dmitry-20s40044rt spotifyd[13705]: subscription terminated
мая 22 13:01:24 dmitry-20s40044rt spotifyd[13705]: Error from channel for data receiver for range 1019904 (+16384).
мая 22 13:01:24 dmitry-20s40044rt spotifyd[13705]: Error from channel for data receiver for range 1003520 (+16384).
мая 22 13:01:24 dmitry-20s40044rt spotifyd[13705]: Connection reset by peer (os error 104)
мая 22 13:00:36 dmitry-20s40044rt spotifyd[13705]: <ДУХОВНАЯ НИЩАНКА> (175986 ms) loaded
мая 22 13:00:36 dmitry-20s40044rt spotifyd[13705]: Loading <ДУХОВНАЯ НИЩАНКА> with Spotify URI spotify:track:2CnXwX8FvX6g8JZc1QSoGX
мая 22 13:00:32 dmitry-20s40044rt spotifyd[13705]: Using Alsa sink with format: S16
мая 22 13:00:32 dmitry-20s40044rt spotifyd[13705]: Country: "TR"
мая 22 13:00:32 dmitry-20s40044rt spotifyd[13705]: Authenticated as "*****" !
мая 22 13:00:32 dmitry-20s40044rt spotifyd[13705]: Connecting to AP "ap.spotify.com:443"
мая 22 13:00:32 dmitry-20s40044rt spotifyd[13705]: Using software volume controller.
мая 22 13:00:32 dmitry-20s40044rt spotifyd[13705]: No proxy specified
мая 22 13:00:32 dmitry-20s40044rt spotifyd[13705]: Loading config from "/home/dmitry/.config/spotifyd/spotifyd.conf"
мая 22 13:00:32 dmitry-20s40044rt systemd[1374]: Started A spotify playing daemon.
мая 22 13:00:32 dmitry-20s40044rt systemd[1374]: Stopped A spotify playing daemon.
мая 22 13:00:32 dmitry-20s40044rt systemd[1374]: Stopping A spotify playing daemon...

@georgefst
Copy link

librespot-org/librespot#427 seems to have corrected the root cause. Now I think spotifyd just needs some changes.

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).

@masonmcelvain
Copy link

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.

<Better Together> (255240 ms) loaded
Unable to load audio item: MercuryError
subscription terminated
Connection reset by peer (os error 104)

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

@homes2001
Copy link

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):

response 200 to GET https://api.spotify.com/v1/tracks/0flf8M
dropping stream: Stream(RustlsStream)
File 51403 complete

Then there is no log output while it is playing. Once the problem appears (connection logst / song stops playing), this is the output:

Connection to server closed.
Invalidating session[0]
drop Dispatch
subscription terminated
drop Spirc[0]
Shutting down player thread ...
drop PlayerInternal[0]
PlayerInternal thread finished.
drop Session[0]
drop AudioKeyManager
drop ChannelManager
drop MercuryManager
deregistering event source from poller
registering event source with poller: token=Token(33554432), interests=READABLE | WRITABLE
signal: Want
signal found waiting giver, notifying
poll_want: taker wants!
signal: Want
signal: Want
Ignoring blacklisted access point ap-gew4.spotify.com:4070
Connecting to AP "ap-guc3.spotify.com:443"
deregistering event source from poller
signal: Closed
registering event source with poller: token=Token(50331648), interests=READABLE | WRITABLE

And then it continues with authenticating a new session ... i can start another song without restarting spotifyd.

@pgranat
Copy link

pgranat commented Jun 9, 2024

Also nordvpn user with same problem here. Managed to somewhat override the problem by whitelisting certain subnets in nordvpn

  1. Prepare list of hosts

Constant:

spclient.wg.spotify.com
apresolve.spotify.com
ap.spotify.com
dealer.spotify.com
api.spotify.com

Dynamic:

$ curl http://apresolve.spotify.com
{"ap_list":["ap-gew4.spotify.com:4070","ap-gew4.spotify.com:443","ap-gew4.spotify.com:80","ap-guc3.spotify.com:4070","ap-gue1.spotify.com:443","ap-gae2.spotify.com:80"]}

So in my case whole list:

spclient.wg.spotify.com
apresolve.spotify.com
ap.spotify.com
dealer.spotify.com
api.spotify.com
ap-gew4.spotify.com
ap-guc3.spotify.com
ap-gue1.spotify.com
ap-gae2.spotify.com
  1. Prepare ip addresses for all hosts. For example (repeat for all addressess):
$ ping ap-gae2.spotify.com
PING ap-gae2.spotify.com (104.199.240.237): 56 data bytes
  1. Whitelist selected host in nordvpn (repeat for all hosts, some can be overlapping):
    $ nordvpn whitelist add subnet 104.199.240.237/32

  2. Restart spotifyd

No problems ever since.
It can be scripted ofc, because addresses or ip resolution can change, will do in the meantime

@m0rt0k
Copy link

m0rt0k commented Jun 22, 2024

Also nordvpn user with same problem here. Managed to somewhat override the problem by whitelisting certain subnets in nordvpn

1. Prepare list of hosts

Constant:

spclient.wg.spotify.com
apresolve.spotify.com
ap.spotify.com
dealer.spotify.com
api.spotify.com

Dynamic:

$ curl http://apresolve.spotify.com
{"ap_list":["ap-gew4.spotify.com:4070","ap-gew4.spotify.com:443","ap-gew4.spotify.com:80","ap-guc3.spotify.com:4070","ap-gue1.spotify.com:443","ap-gae2.spotify.com:80"]}

So in my case whole list:

spclient.wg.spotify.com
apresolve.spotify.com
ap.spotify.com
dealer.spotify.com
api.spotify.com
ap-gew4.spotify.com
ap-guc3.spotify.com
ap-gue1.spotify.com
ap-gae2.spotify.com
2. Prepare ip addresses for all hosts. For example (repeat for all addressess):
$ ping ap-gae2.spotify.com
PING ap-gae2.spotify.com (104.199.240.237): 56 data bytes
3. Whitelist selected host in nordvpn (repeat for all hosts, some can be overlapping):
   `$ nordvpn whitelist add subnet 104.199.240.237/32`

4. Restart spotifyd

No problems ever since. It can be scripted ofc, because addresses or ip resolution can change, will do in the meantime

This worked for me, thank you very much.
Short script:

curl "http://apresolve.spotify.com" | jq -cr '.ap_list[]' | while read -r i; do
    ip=$(getent hosts "${i%:*}" | awk '{print$1}')
    nordvpn whitelist add subnet "$ip/32"
done

@mietzen
Copy link
Contributor

mietzen commented Sep 27, 2024

Mullvad user here I just used tinyproxy on a host without VPN and the --proxy option to not use the VPN tunnel for spotifyd

@artenverho
Copy link

artenverho commented Oct 5, 2024

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?

@mietzen
Copy link
Contributor

mietzen commented Oct 6, 2024

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 to have spotifyd to have the same fix (my own setup heavily relies on the dubs 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 Cargo.toml:

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 Log
build-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:

git clone https://github.com/Spotifyd/spotifyd.git

Change the Cargo.toml.

Run cargo update and cargo build --release

or use dockerwith this docker-compose.yml to have clean build enviroment:

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

@artenverho
Copy link

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 to have spotifyd to have the same fix (my own setup heavily relies on the dubs 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 Cargo.toml:

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 Log
If you want to try to debug / fix it yourself:

git clone https://github.com/Spotifyd/spotifyd.git

Change the Cargo.toml.

Run cargo update and cargo build --release

or use dockerwith this docker-compose.yml to have clean build enviroment:

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.

@alepez
Copy link

alepez commented Oct 16, 2024

It seems that librespot v0.5.0 has been released with the fix

@BSoDium
Copy link

BSoDium commented Nov 27, 2024

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.
It's not the neatest solution, but it works and does not require human interaction, which is what I was aiming for.

The following was tested on Debian bookworm:

  • Create /usr/local/bin/spotifyd-failsafe.sh:

    # replace "spotifyd" with the name of your service running spotifyd if needed
    journalctl -u spotifyd -f | while read -r line; do
        if echo "$line" | grep -q "Connection reset by peer"; then
            systemctl restart spotifyd
        fi
    done
  • Make it executable:

    sudo chmod +x /usr/local/bin/spotifyd-failsafe.sh
  • Create the service at /etc/systemd/system/spotifyd-failsafe.service:

    [Unit]
    Description=Restart spotifyd when it silently fails
    After=spotifyd.service
    
    [Service]
    ExecStart=/usr/local/bin/spotifyd-failsafe.sh
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
  • Reload then enable the service:

    sudo systemctl daemon-reload
    sudo systemctl enable spotifyd-failsafe.service
    sudo systemctl start spotifyd-failsafe.service

@eladyn
Copy link
Member

eladyn commented Dec 30, 2024

If anyone wants to try the PR which upgrades librespot to 0.6.0 (#1317 / #1321) and see if it fixes the problem, that would be very welcome!

@steabert
Copy link

steabert commented Jan 1, 2025

If anyone wants to try the PR which upgrades librespot to 0.6.0 (#1317 / #1321) and see if it fixes the problem, that would be very welcome!

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.

@mietzen
Copy link
Contributor

mietzen commented Jan 1, 2025

If anyone wants to try the PR which upgrades librespot to 0.6.0 (#1317 / #1321) and see if it fixes the problem, that would be very welcome!

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, docker-compose.yml:

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

@steabert
Copy link

steabert commented Jan 4, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A functionality or parts of a program that do not work as intended
Projects
None yet
Development

No branches or pull requests