spotifyd icon indicating copy to clipboard operation
spotifyd copied to clipboard

Device disappears after being idle for some hours

Open Semmu opened this issue 3 years ago • 42 comments

Description Hi,

I have recently bought a new router (TP-Link Archer AX1800) and since then spotifyd always disappears from my Spotify Connect devices list after some hours of being idle (e.g. I leave my home). This is always happening, though the timeout does seem to vary a bit.

Because it happens since the introduction of my new router, I suspect some networking issue, like some TCP connection being closed despite still in use, even if barely.

Unfortunately spotifyd does not realize its connection has been closed and does not restart automatically (which would solve the problem), nothing interesting is printed in the logs, so I always have to restart the service manually, which is pretty annoying.

Could you please implement some heartbeat check or more pedantic network connection handling, so maybe it can detect connection issues and reconnect if needed?

Thanks in advance!

To Reproduce 0. (buy and use TP-Link Archer AX1800)

  1. Start spotifyd, play some music
  2. Stop playing music, but keep spotifyd running
  3. Leave spotifyd alone for some hours
  4. Notice that spotifyd is not in the Spotify Connect devices list anymore 😞

Expected behavior 4. Notice that spotifyd is still in the Spotify Connect devices list 😊

Logs

Click to show logs

Nothing special in the logs, but I did not run it with --verbose. Made the change now, and will include the logs here when I encounter the issue next time.

Compilation flags

  • [ ] dbus_mpris
  • [ ] dbus_keyring
  • [x] alsa_backend
  • [ ] portaudio_backend
  • [ ] pulseaudio_backend
  • [ ] rodio_backend

(Downloaded the binary release from here.)

Versions (please complete the following information):

  • OS: Ubuntu 18.04.5 LTS bionic (Linux 4.14.180-178 #1 SMP PREEMPT Wed Sep 2 12:39:45 -03 2020 armv7l armv7l armv7l GNU/Linux)
  • Spotifyd: spotifyd 0.3.0
  • cargo: not installed

Semmu avatar Feb 25 '21 11:02 Semmu

It happened again and there is nothing related found in the logs, even with verbose logging enabled.

Screenshot of evidence: spotifyd running without issues, but it does not show up in the devices list.

Screenshot 2021-02-26 at 14 35 58

Semmu avatar Feb 26 '21 13:02 Semmu

Thanks for the bug report! i have not seen this before. Could you try to run https://github.com/librespot-org/librespot on its own and see if it still happens, its the depency we use for the spotify connection.

robinvd avatar Mar 03 '21 09:03 robinvd

good point, i will try that

Semmu avatar Mar 03 '21 12:03 Semmu

Also happens to me i have a MS-7B00 as my motherboard. And Im running the systemctl user process.

pwall2222 avatar Mar 11 '21 20:03 pwall2222

I experience the same issue on OSX 11.2.3 (20D91) and spotifyd 0.3.2 .

Im using https://github.com/Rigellute/spotify-tui to connect. I found out that my MacSound device disappear after idle. As @Semmu said there are no logs im trying to find the root cause. Laptop is always connected to Ethernet ( don't use WIFI ).

vhristev avatar Apr 08 '21 08:04 vhristev

I have exactly the same problem on raspberry pi 3 with wifi connection

friedemannm avatar May 07 '21 21:05 friedemannm

I'm also experiencing the exact same issue on my Raspberry Pi 3 that runs ArchLinux with spotifyd v0.3.2. I suspect this might be related to #706.

Is there any way to add a healtcheck to the spotifyd daemon, to make it query the list of devices on the Spotify API and re-register itself if it's missing from there? Otherwise a workaround would be a script that performs that check, and marks the spotifyd system service as 'stopped' to force a restart.

shiraneyo avatar May 21 '21 21:05 shiraneyo

Same problem here, trying to use spotifyd as my main client and if I stop using it for some hours spotifyd just disappears and stop responding. The spotifyd process keeps running as a zombie.

emanuelserpa avatar Jul 01 '21 13:07 emanuelserpa

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[bot] avatar Sep 29 '21 14:09 stale[bot]

This bot is so problematic... The issue is still relevant.

cauebs avatar Sep 29 '21 17:09 cauebs

The issue is still relevant I still need to restart the spotifyd before i use 'spt' otherwise i dont have my Mac as output device.

vhristev avatar Oct 10 '21 16:10 vhristev

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[bot] avatar Jan 13 '22 17:01 stale[bot]

Issue still relevant

emanuelserpa avatar Jan 13 '22 20:01 emanuelserpa

Has anyone ever tried this proposal to track down, what causes this problem?

eladyn avatar Jan 13 '22 22:01 eladyn

I guess I first need to install plain librespot for this, right? I haven't really figured out the relation between spotifyd and librespot

BlackYps avatar Jan 16 '22 13:01 BlackYps

Yeah, you can have a look at their README on how to do this.

As far as I know, librespot provides several things: It can be used as a library, to build a custom spotify client, which is done by e.g. spotifyd, ncspot, spot and many others. Alternatively, it can be installed as a binary and as such be used as a standalone client. This is something that is done by e.g. raspotify or when you install it directly via cargo install.

So in this case, trying librespot in its standalone version can show, wether the problem lies the way spotifyd uses librespot or if librespot itself has the bug in its upstream version as well.

eladyn avatar Jan 16 '22 14:01 eladyn

I found out that my Pi Zero 2 W can't handle building the rust packages. I tried to do it on my PC instead, but obviously I have to cross-compile, because the Pi uses arm architecture. I already spent a lot of time now, I am no closer to a solution and it is obvious that it will have to spend a lot more time to understand rust compilation. At this point it seems more reasonable for me to try my luck with raspotify and see if the issue also happens there. For the issue with spotifyd here I am afraid I can't contribute any more, sadly.

BlackYps avatar Jan 16 '22 18:01 BlackYps

Sure, no worries. Thanks for trying!

But if it works for you with raspotify that would still be valuable information, since raspotify just executes the librespot binary and wraps it into a debian package, IIRC. So running it successfully would then mean that at least the newest librespot does not suffer from the problem.

eladyn avatar Jan 16 '22 19:01 eladyn

good news, I discovered that when you install raspotify you can also use librespot directly. I will report back when I have tested it for a while to see if the original bug described here surfaces again

BlackYps avatar Jan 16 '22 19:01 BlackYps

I can confirm that it still happens when using plain librespot. I also found a related issue: https://github.com/librespot-org/librespot/issues/247 Note that the issue itself is closed because the underlying issue is discussed here: https://github.com/librespot-org/librespot/discussions/609

BlackYps avatar Jan 17 '22 10:01 BlackYps

I have the same problem, but only on 1 of 3 devices. I run spotifd version 0.3.3 . I have used raspotify, which uses librespot, for a few years. In June 2022 with the new version of spotify, the API broke, so I switched to spotfifyd with success. I have 3 raspberry pi's running this software. 2 are running ok, but one device will disapear after somte time in spotify when nothing is played. This pi is behind an extra switch. With raspotify I had exactly the same behaviour. After restarting spotifyd on this pi, everything works ok for a while. The other two pi's never have this problem.

Quest24 avatar Jul 25 '22 16:07 Quest24

I have the same issue on a Raspberry Pi 4, running ppotifyd 3.3.0 on nixos connected to a Fritzbox 7362 SL via wifi.

AberDerBart avatar Sep 26 '22 08:09 AberDerBart

I actually managed to solve this problem indirectly by turning off a lot of "advanced" features in my router a long time ago. I guess those settings somehow caused spotifyd to disconnect. Unfortunately I don't remember the exact features I turned off, because I didn't think it will have any effect on this issue.

But I recommend playing around in your router settings if you have the option.

@Quest24 's answer also seems to support this theory as he has an extra switch in front of the problematic spotifyd, so I guess his problem is the same.

Semmu avatar Sep 27 '22 20:09 Semmu

Well, it started disappearing for me very frequently again, since a week or so... And I didn't change a thing, not in my network, nor did I upgrade my spotifyd version. So I suspect something has been changed on the other side of the equation, I think the devs did something at Spotify.

Does any of you experience a sudden increase of spotifyd disappearing?

Semmu avatar Nov 16 '22 18:11 Semmu

Well for one Spotify changed it's sdk recently so maybe there are some issues with that.

pwall2222 avatar Nov 16 '22 20:11 pwall2222

I tried it yesterday, but the problem is stil there. After one day, one device will disappear from the list. After restarting it becomes visibable again. Everything will work as long as a play music on that device, but wil disappear after stop playing.

Quest24 avatar Nov 25 '22 10:11 Quest24

I experienced this today. Restarting the systemd service makes it reappear, but I don't see anything unusual when I run journalctl

allys7 avatar Dec 13 '22 22:12 allys7

same here. running on a raspberry pi 4 8GB with docker. after serval hours the device is not listed.

seekwhencer avatar Mar 04 '23 15:03 seekwhencer

Can confirm that this happens both with spotifyd and Raspotify when running alongside OSMC

vguttmann avatar Mar 16 '23 12:03 vguttmann

Thanks for the confirmations, I just found this issue over at the librespot repo, which seems to describe the exact same problem. So this could be fixed by checking for timeouts on the Ping-Pong commands in librespot.

eladyn avatar Mar 17 '23 00:03 eladyn