[GH-ISSUE #240] Stuck after "Failed restoring session after logout" #153

Closed
opened 2026-02-28 14:25:50 +03:00 by kerem · 3 comments
Owner

Originally created by @2opremio on GitHub (Nov 3, 2025).
Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/240

go-librespot gets stuck after Failed restoring session after logout

Oct 28 06:59:00 duchamp go-librespot[18070]: time="2025-10-28T06:59:00Z" level=info msg="authenticated Login5" username="aa***ta"
Oct 28 06:59:02 duchamp go-librespot[18070]: time="2025-10-28T06:59:02Z" level=info msg="loaded track \"Please, Please, Please\" (paused: false, position: 0ms, duration: 164466ms, prefetched: false)" uri="spotify:track:72mLXc1VACc051L08tPHBK"
Oct 28 06:59:18 duchamp go-librespot[18070]: time="2025-10-28T06:59:18Z" level=info msg="playback was transferred to <unknown>"
Oct 28 06:59:19 duchamp go-librespot[18070]: time="2025-10-28T06:59:19Z" level=info msg="loading previously persisted zeroconf credentials" username="aa***ta"
Oct 28 07:09:19 duchamp go-librespot[18070]: time="2025-10-28T07:09:19Z" level=error msg="failed restoring session after logout" error="failed authenticating accesspoint with stored credentials: failed performing keyexchange: failed reading APResponseMessage message: failed reading message length: EOF"

It reauthenticated upon a manual restart without problems:

 09:26:29 duchamp systemd[1]: Stopping go-librespot.service - Yet another open-source Spotify Connect compatible client, written in Go...
Nov 03 09:26:29 duchamp systemd[1]: go-librespot.service: Deactivated successfully.
Nov 03 09:26:29 duchamp systemd[1]: Stopped go-librespot.service - Yet another open-source Spotify Connect compatible client, written in Go.
Nov 03 09:26:29 duchamp systemd[1]: go-librespot.service: Consumed 23min 55.164s CPU time.
Nov 03 09:26:29 duchamp systemd[1]: Started go-librespot.service - Yet another open-source Spotify Connect compatible client, written in Go.
Nov 03 09:26:29 duchamp go-librespot[23113]: time="2025-11-03T09:26:29Z" level=info msg="running go-librespot f392d6e9"
Nov 03 09:26:29 duchamp go-librespot[23113]: time="2025-11-03T09:26:29Z" level=info msg="api server listening on 127.0.0.1:3678"
Nov 03 09:26:29 duchamp go-librespot[23113]: time="2025-11-03T09:26:29Z" level=info msg="zeroconf server listening on port 37869"
Nov 03 09:26:29 duchamp go-librespot[23113]: time="2025-11-03T09:26:29Z" level=info msg="loading previously persisted zeroconf credentials" username="aa***ta"
Nov 03 09:26:29 duchamp go-librespot[23113]: time="2025-11-03T09:26:29Z" level=info msg="authenticated AP" username="aa***ta"
Nov 03 09:26:29 duchamp go-librespot[23113]: time="2025-11-03T09:26:29Z" level=info msg="authenticated Login5" username="aa***ta

It may have been a legitimate error at the time, but the process shouldn't get stuck. Even crashing (and letting the OS restart it if configured like that) is better than being unauthenticated and completely nonfunctional.

I've noticed that it's become increasingly difficult to have go-librespot as a long-running daemon process. Most of the times, when I try to use it it either fails to tranfer the session or is stuck in an irrecoverable state without manual intervention (See https://github.com/devgianlu/go-librespot/issues/228 and https://github.com/devgianlu/go-librespot/issues/238 and a few others which have been resolved, thanks). I'm starting to consider either switching product or working around it by having a cronjob restarting it every hour (but I would hate to do this)

@devgianlu Don't get me wrong, I am really thankful for your hard work I love the project! It's just that, as a user, it's become difficult to deal with. Particularly since I originally came from using https://github.com/Spotifyd/spotifyd looking for a better maintained alternative.

You could say, "OK, then contribute and fix the problems", and you would be right! But I don't have the time.

Originally created by @2opremio on GitHub (Nov 3, 2025). Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/240 `go-librespot` gets stuck after `Failed restoring session after logout` ``` Oct 28 06:59:00 duchamp go-librespot[18070]: time="2025-10-28T06:59:00Z" level=info msg="authenticated Login5" username="aa***ta" Oct 28 06:59:02 duchamp go-librespot[18070]: time="2025-10-28T06:59:02Z" level=info msg="loaded track \"Please, Please, Please\" (paused: false, position: 0ms, duration: 164466ms, prefetched: false)" uri="spotify:track:72mLXc1VACc051L08tPHBK" Oct 28 06:59:18 duchamp go-librespot[18070]: time="2025-10-28T06:59:18Z" level=info msg="playback was transferred to <unknown>" Oct 28 06:59:19 duchamp go-librespot[18070]: time="2025-10-28T06:59:19Z" level=info msg="loading previously persisted zeroconf credentials" username="aa***ta" Oct 28 07:09:19 duchamp go-librespot[18070]: time="2025-10-28T07:09:19Z" level=error msg="failed restoring session after logout" error="failed authenticating accesspoint with stored credentials: failed performing keyexchange: failed reading APResponseMessage message: failed reading message length: EOF" ``` It reauthenticated upon a manual restart without problems: ``` 09:26:29 duchamp systemd[1]: Stopping go-librespot.service - Yet another open-source Spotify Connect compatible client, written in Go... Nov 03 09:26:29 duchamp systemd[1]: go-librespot.service: Deactivated successfully. Nov 03 09:26:29 duchamp systemd[1]: Stopped go-librespot.service - Yet another open-source Spotify Connect compatible client, written in Go. Nov 03 09:26:29 duchamp systemd[1]: go-librespot.service: Consumed 23min 55.164s CPU time. Nov 03 09:26:29 duchamp systemd[1]: Started go-librespot.service - Yet another open-source Spotify Connect compatible client, written in Go. Nov 03 09:26:29 duchamp go-librespot[23113]: time="2025-11-03T09:26:29Z" level=info msg="running go-librespot f392d6e9" Nov 03 09:26:29 duchamp go-librespot[23113]: time="2025-11-03T09:26:29Z" level=info msg="api server listening on 127.0.0.1:3678" Nov 03 09:26:29 duchamp go-librespot[23113]: time="2025-11-03T09:26:29Z" level=info msg="zeroconf server listening on port 37869" Nov 03 09:26:29 duchamp go-librespot[23113]: time="2025-11-03T09:26:29Z" level=info msg="loading previously persisted zeroconf credentials" username="aa***ta" Nov 03 09:26:29 duchamp go-librespot[23113]: time="2025-11-03T09:26:29Z" level=info msg="authenticated AP" username="aa***ta" Nov 03 09:26:29 duchamp go-librespot[23113]: time="2025-11-03T09:26:29Z" level=info msg="authenticated Login5" username="aa***ta ``` It may have been a legitimate error at the time, but the process shouldn't get stuck. Even crashing (and letting the OS restart it if configured like that) is better than being unauthenticated and completely nonfunctional. I've noticed that it's become increasingly difficult to have go-librespot as a long-running daemon process. Most of the times, when I try to use it it either fails to tranfer the session or is stuck in an irrecoverable state without manual intervention (See https://github.com/devgianlu/go-librespot/issues/228 and https://github.com/devgianlu/go-librespot/issues/238 and a few others which have been resolved, thanks). I'm starting to consider either switching product or working around it by having a cronjob restarting it every hour (but I would hate to do this) @devgianlu Don't get me wrong, I am really thankful for your hard work I love the project! It's just that, as a user, it's become difficult to deal with. Particularly since I originally came from using https://github.com/Spotifyd/spotifyd looking for a better maintained alternative. You could say, "OK, then contribute and fix the problems", and you would be right! But I don't have the time.
kerem 2026-02-28 14:25:50 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@markferry commented on GitHub (Nov 5, 2025):

I suspect I have been hitting this too - with 8 instances of go-librespot running it seems to happen about once a day.

Running now with debug logging to try reproducing...

<!-- gh-comment-id:3492391342 --> @markferry commented on GitHub (Nov 5, 2025): I suspect I have been hitting this too - with 8 instances of go-librespot running it seems to happen about once a day. Running now with debug logging to try reproducing...
Author
Owner

@blattm commented on GitHub (Nov 27, 2025):

Happens to me as well :/

The "loading previously persisted zeroconf credentials" message makes me think, that maybe the problem does not occur if zerconf credential storage is disabled...
I just started using this configuration and in case the issue reappears, I'll let you know.

Until this is properly fixed, a simple workaround would be to just exit in the "main.go" where the "failed restoring session..." is printed.

<!-- gh-comment-id:3587089437 --> @blattm commented on GitHub (Nov 27, 2025): Happens to me as well :/ The "loading previously persisted zeroconf credentials" message makes me think, that maybe the problem does not occur if zerconf credential storage is disabled... I just started using this configuration and in case the issue reappears, I'll let you know. Until this is properly fixed, a simple workaround would be to just exit in the "main.go" where the "failed restoring session..." is printed.
Author
Owner

@markferry commented on GitHub (Nov 27, 2025):

diff --git a/cmd/daemon/main.go b/cmd/daemon/main.go
index f56da42..208a0bf 100644
--- a/cmd/daemon/main.go
+++ b/cmd/daemon/main.go
@@ -306,7 +306,7 @@ func (app *App) withAppPlayer(ctx context.Context, appPlayerFunc func(context.Co
                                // we will restore the session even if it's for the same user, but it shouldn't be an issue
                                newAppPlayer, err := appPlayerFunc(ctx)
                                if err != nil {
-                                       log.WithError(err).Errorf("failed restoring session after logout")
+                                       log.Fatalf("Failed restoring session after logout: %v", err)
                                } else if newAppPlayer == nil {
                                        // unset the zeroconf user
                                        z.SetCurrentUser("")
<!-- gh-comment-id:3587209964 --> @markferry commented on GitHub (Nov 27, 2025): ```diff diff --git a/cmd/daemon/main.go b/cmd/daemon/main.go index f56da42..208a0bf 100644 --- a/cmd/daemon/main.go +++ b/cmd/daemon/main.go @@ -306,7 +306,7 @@ func (app *App) withAppPlayer(ctx context.Context, appPlayerFunc func(context.Co // we will restore the session even if it's for the same user, but it shouldn't be an issue newAppPlayer, err := appPlayerFunc(ctx) if err != nil { - log.WithError(err).Errorf("failed restoring session after logout") + log.Fatalf("Failed restoring session after logout: %v", err) } else if newAppPlayer == nil { // unset the zeroconf user z.SetCurrentUser("") ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/go-librespot#153
No description provided.