librespot: Connection reset by peer (os error 104)
Describe the bug
Librespot keeps crashing on random intervals. I implemented the 0.0.0.0 apresolve.spotify.com bypass in /etc/hosts, but now this issue just replaced the other one: https://github.com/librespot-org/librespot/issues/1322
To reproduce
- Launch
librespotwith
stream = spotify:///librespot?name=Spotify&devicename=HA_Snapcast&bitrate=320&volume=100&cache=/data/librespot&cache-size-limit=2G&autoplay=true¶ms=--disable-discovery
- Start playing media
- Crashes on random intervals
Log
... SNIP ...
2024-09-16 12-09-53.469 [Error] (librespot_core::session) Connection reset by peer (os error 104)
2024-09-16 12-09-53.469 [Error] (librespot_connect::spirc) subscription terminated
2024-09-16 12-09-53.469 [Error] (librespot_playback::player) Unable to load audio item: MercuryError
2024-09-16 12-09-53.475 [Warn] (librespot) Spirc shut down unexpectedly
2024-09-16 12-09-53.475 [Warn] (librespot_core::apresolve) Failed to resolve Access Point: error trying to connect: tcp connect error: Connection refused (os error 111)
2024-09-16 12-09-53.475 [Warn] (librespot_core::apresolve) Using fallback "ap.spotify.com:443"
2024-09-16 12-09-53.475 [Info] (librespot_core::session) Connecting to AP "ap.spotify.com:443"
2024-09-16 12-09-53.811 [Info] (librespot_core::session) Authenticated as "x" !
2024-09-16 12-09-53.812 [Info] (librespot_playback::mixer::softmixer) Mixing with softvol and volume control: Log(60.0)
... SNIP ...
Host (what you are running librespot on):
- OS: Debian container, through Snapcast
- Platform: HAOS x86
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 15
- Comments: 52 (30 by maintainers)
It seems to be getting worse for me… this evening it is giving me the error almost every 30min… is there any way to debug this?
@rwjack @artenverho @herrernst @ius @tla44 could you test whether #1357 fixes the issue for you?
I was able to keep librespot running for 7h+ with that patch applied without a single reconnect.
I’ll follow up with some A/B testing to be sure (unless enough others confirm it works for them).
There’s a revised implementation of the modified keep-alive handling in #1359. It should behave the same as #1357, but it’d be great if any of you could give it a quick test as well!
What I’m seeing is (Spotify Desktop on Linux)
i.e. the sequence is always the same, even after start-up.
I could open a PR with a quick & dirty fix, but I can’t easily test it myself: The disconnects don’t happen so frequently for me right now, so it’s hard to say whether there’s any difference (it might run for half an hour without connection resets).
EDIT: The
Pongpayload seems to be always zero.Thanks for this PR.
Tested with https://github.com/librespot-org/librespot/pull/1359 I no longer have
os error 104.But, now, even when I don’t listen music, I get a
os error 107. I don’t know if this is related to this PR, or a network issue, or something else. To my knowledge, I never had this error before.I’m running 4 instances of librespot with snapcast, on a VM machine (Proxmox VE 8.1)
Here is a log when error happens in the night, when nobody is listening music:
Had already spotted it and it’s been running at least as well as the v1 for me for the past two days.
Thanks in particular also to @kingosticks for the initial diagnosis!
Excellent, I missed that. Do you want to PR those spotify-analyze fixes too?
Oh, that’s why I also updated
dump.c: The patch that is applied to the executable affects several processes that concurrently write to the same file, corrupting it (only one process actually communicates with the server, but all of them write the pcap header). You’ll have tomakeagain and collect new dumps. It will now write todump-<PID>.pcapfiles. Select the right one for analysis by file size.Here's a patch for Wireshark 4.2: