spotifyd
spotifyd copied to clipboard
ConnectionReset - Spotifyd stops playing
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
- [x] alsa_backend
- [ ] portaudio_backend
- [ ] pulseaudio_backend
- [ ] rodio_backend Using pre-built binary
Versions (please complete the following information):
- OS: Debian Buster, 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux
- Spotifyd: v0.2.24
- cargo: n/a?
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.
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" }
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 :slightly_smiling_face: Edit: The bot did it.
https://github.com/librespot-org/librespot/pull/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:
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
Same issue on manjaro linux. @emz229 your link to the librespot discussion is broken.
@stevensonmt Thanks for pointing that out... for some reason it is redirecting wrong, updated link: https://github.com/librespot-org/librespot/discussions/609
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.
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...
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).
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
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.