mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[GH-ISSUE #1617] Reconnection issues after suspend #738
Labels
No labels
A-Alsa
SpotifyAPI
Tokio 1.0
audio
bug
can't reproduce
compilation
dependencies
duplicate
enhancement
good first issue
help wanted
high priority
imported
imported
invalid
new api
pull-request
question
reverse engineering
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot#738
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @zappolowski on GitHub (Oct 24, 2025).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/1617
Description
Librespot fails to reconnect after system suspend, tries reconnecting indefinitely.
Version
Latest dev (
9142e6941bas time of writing).How to reproduce
librespotwith OAuth or zeroconf (user name and password authentication wasn't tested, but I would assume to behave the same)Log
That log line is repeated until the process is stopped (or maybe after an hour has passed, haven't tested that one).
Host
Additional context
I tracked it down to
librespot_core::token::Token::is_expired(&self). This usesstd::time::Instantto check whether a token is expired. On Linuxstd::time::InstantusesCLOCK_MONOTONIC(see here) which is paused during suspend and thus that check still considers the token to be valid while in fact it's already expired. I added some logging to prove thisThe system was suspended for about eight hours, but for the check only thirty seconds have passed.
I got it to work for me by switching to
std::time::SystemTime, but this has issues by being not monotonically increasing. Best would be to useCLOCK_BOOTTIMEon Linux, which doesn't seem feasible at the moment, but I foundboot-time, which could be a drop-in replacement for this use case.@roderickvd commented on GitHub (Oct 24, 2025):
Oh wow good one. When you changed to
SystemTime, what did you use:elapsed? Thoughboot-timeseems relatively lightweight from the outset, if we can manage to stay withinstdthat’d be nice, and I wonder ifSystemTimenot monotically increasing will actually be a problem.@zappolowski commented on GitHub (Oct 24, 2025):
For testing I just replaced calls to
Instant::now()withSystemTime::now()and adjusted the type of the field.