[GH-ISSUE #1456] CLI Application freezes when trying to connect #654

Closed
opened 2026-02-27 19:31:47 +03:00 by kerem · 5 comments
Owner

Originally created by @Timboooh on GitHub (Jan 24, 2025).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/1456

Description

I'm using the example command listed in the usage section of the README.
Librespot starts up as usual and is detected properly in the Spotify Desktop Client.
When I try to connect the librespot application freezes, and can't be terminated using the CTRL+C shortcut.
I've tried it on my home network and also on LTE using an Android Hotspot.

Version

$ librespot --version
'librespot 0.6.0 VERGEN_IDEMPOTENT_OUTPUT (Built on 2025-01-24, Build ID: jn3b7UuP, Profile: release)

How to reproduce

  1. Launch librespot --verbose --name librespot
  2. Connect using Spotify Desktop Client
  3. Spotify Desktop gets stuck on 'Connecting to librespot' and fails after a while
  4. Librespot freezes

Log

librespot --verbose --name librespot
[2025-01-24T16:07:44Z INFO  librespot] librespot 0.6.0 VERGEN_IDEMPOTENT_OUTPUT (Built on 2025-01-24, Build ID: jn3b7UuP, Profile: release)
[2025-01-24T16:07:44Z TRACE librespot] Command line argument(s):
[2025-01-24T16:07:44Z TRACE librespot]          verbose
[2025-01-24T16:07:44Z TRACE librespot]          name "librespot"
[2025-01-24T16:07:44Z DEBUG librespot_core::session] new Session
[2025-01-24T16:07:44Z DEBUG librespot_discovery::server] Zeroconf server listening on 0.0.0.0:37773
[2025-01-24T16:07:44Z INFO  librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Log(60.0)
[2025-01-24T16:07:44Z DEBUG librespot_playback::player] new Player [0]
[2025-01-24T16:07:44Z INFO  librespot_playback::convert] Converting with ditherer: tpdf
[2025-01-24T16:07:44Z INFO  librespot_playback::audio_backend::rodio] Using Rodio sink with format S16 and cpal host: ALSA
[2025-01-24T16:07:44Z INFO  librespot_playback::audio_backend::rodio] Using audio device: default
[2025-01-24T16:07:44Z DEBUG librespot_playback::audio_backend::rodio] Rodio sink was created
[2025-01-24T16:07:49Z DEBUG librespot_discovery::server] POST "/" {}
[2025-01-24T16:07:49Z DEBUG librespot_core::session] Shutdown: Invalidating session
[2025-01-24T16:07:49Z DEBUG librespot::component] new MercuryManager
[2025-01-24T16:07:49Z DEBUG librespot::component] new ChannelManager
[2025-01-24T16:07:49Z DEBUG librespot_core::session] new Session
[2025-01-24T16:07:49Z DEBUG librespot_connect::spirc] new Spirc[0]
[2025-01-24T16:07:49Z DEBUG librespot::component] new MercuryManager
[2025-01-24T16:07:49Z DEBUG librespot::component] new SpClient
[2025-01-24T16:07:49Z DEBUG librespot_core::spclient] Client token unavailable or expired, requesting new token.
[2025-01-24T16:07:49Z DEBUG librespot_playback::player] command=SetSession
[2025-01-24T16:07:49Z DEBUG librespot_core::session] drop Session
[2025-01-24T16:07:49Z DEBUG librespot::component] drop ChannelManager
[2025-01-24T16:07:49Z DEBUG librespot::component] drop MercuryManager
[2025-01-24T16:07:49Z DEBUG librespot_core::http_client] Requesting https://clienttoken.spotify.com/v1/clienttoken
[2025-01-24T16:07:49Z DEBUG librespot_core::spclient] Received a granted token
[2025-01-24T16:07:49Z TRACE librespot_core::spclient] Got client token: GrantedTokenResponse { token: "xxx", expires_after_seconds: 1216800, refresh_after_seconds: 1209600, domains: [TokenDomain { domain: "spotify.com", special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } }, TokenDomain { domain: "spotify.net", special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } }], special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } }
[2025-01-24T16:07:49Z DEBUG librespot::component] new ApResolver
[2025-01-24T16:07:49Z DEBUG librespot_core::http_client] Requesting https://apresolve.spotify.com/?type=accesspoint&type=dealer&type=spclient
[2025-01-24T16:07:49Z INFO  librespot_core::session] Connecting to AP "ap-gew4.spotify.com:4070"
[2025-01-24T16:08:22Z DEBUG librespot_discovery::server] POST "/" {}
[2025-01-24T16:08:52Z DEBUG librespot_discovery::server] POST "/" {}
[2025-01-24T16:09:22Z DEBUG librespot_discovery::server] POST "/" {}

Host (what you are running librespot on):

  • OS: Ubuntu Desktop 22.04.5 LTS
  • Platform: x86_64 Dell Laptop

Thanks in advance for your help. Please ask if you need more information.

Originally created by @Timboooh on GitHub (Jan 24, 2025). Original GitHub issue: https://github.com/librespot-org/librespot/issues/1456 ### Description I'm using the example command listed in the usage section of the README. Librespot starts up as usual and is detected properly in the Spotify Desktop Client. When I try to connect the librespot application freezes, and can't be terminated using the CTRL+C shortcut. I've tried it on my home network and also on LTE using an Android Hotspot. ### Version ``` $ librespot --version 'librespot 0.6.0 VERGEN_IDEMPOTENT_OUTPUT (Built on 2025-01-24, Build ID: jn3b7UuP, Profile: release) ``` ### How to reproduce 1. Launch `librespot --verbose --name librespot` 2. Connect using Spotify Desktop Client 3. Spotify Desktop gets stuck on 'Connecting to librespot' and fails after a while 4. Librespot freezes ### Log ``` librespot --verbose --name librespot [2025-01-24T16:07:44Z INFO librespot] librespot 0.6.0 VERGEN_IDEMPOTENT_OUTPUT (Built on 2025-01-24, Build ID: jn3b7UuP, Profile: release) [2025-01-24T16:07:44Z TRACE librespot] Command line argument(s): [2025-01-24T16:07:44Z TRACE librespot] verbose [2025-01-24T16:07:44Z TRACE librespot] name "librespot" [2025-01-24T16:07:44Z DEBUG librespot_core::session] new Session [2025-01-24T16:07:44Z DEBUG librespot_discovery::server] Zeroconf server listening on 0.0.0.0:37773 [2025-01-24T16:07:44Z INFO librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Log(60.0) [2025-01-24T16:07:44Z DEBUG librespot_playback::player] new Player [0] [2025-01-24T16:07:44Z INFO librespot_playback::convert] Converting with ditherer: tpdf [2025-01-24T16:07:44Z INFO librespot_playback::audio_backend::rodio] Using Rodio sink with format S16 and cpal host: ALSA [2025-01-24T16:07:44Z INFO librespot_playback::audio_backend::rodio] Using audio device: default [2025-01-24T16:07:44Z DEBUG librespot_playback::audio_backend::rodio] Rodio sink was created [2025-01-24T16:07:49Z DEBUG librespot_discovery::server] POST "/" {} [2025-01-24T16:07:49Z DEBUG librespot_core::session] Shutdown: Invalidating session [2025-01-24T16:07:49Z DEBUG librespot::component] new MercuryManager [2025-01-24T16:07:49Z DEBUG librespot::component] new ChannelManager [2025-01-24T16:07:49Z DEBUG librespot_core::session] new Session [2025-01-24T16:07:49Z DEBUG librespot_connect::spirc] new Spirc[0] [2025-01-24T16:07:49Z DEBUG librespot::component] new MercuryManager [2025-01-24T16:07:49Z DEBUG librespot::component] new SpClient [2025-01-24T16:07:49Z DEBUG librespot_core::spclient] Client token unavailable or expired, requesting new token. [2025-01-24T16:07:49Z DEBUG librespot_playback::player] command=SetSession [2025-01-24T16:07:49Z DEBUG librespot_core::session] drop Session [2025-01-24T16:07:49Z DEBUG librespot::component] drop ChannelManager [2025-01-24T16:07:49Z DEBUG librespot::component] drop MercuryManager [2025-01-24T16:07:49Z DEBUG librespot_core::http_client] Requesting https://clienttoken.spotify.com/v1/clienttoken [2025-01-24T16:07:49Z DEBUG librespot_core::spclient] Received a granted token [2025-01-24T16:07:49Z TRACE librespot_core::spclient] Got client token: GrantedTokenResponse { token: "xxx", expires_after_seconds: 1216800, refresh_after_seconds: 1209600, domains: [TokenDomain { domain: "spotify.com", special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } }, TokenDomain { domain: "spotify.net", special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } }], special_fields: SpecialFields { unknown_fields: UnknownFields { fields: None }, cached_size: CachedSize { size: 0 } } } [2025-01-24T16:07:49Z DEBUG librespot::component] new ApResolver [2025-01-24T16:07:49Z DEBUG librespot_core::http_client] Requesting https://apresolve.spotify.com/?type=accesspoint&type=dealer&type=spclient [2025-01-24T16:07:49Z INFO librespot_core::session] Connecting to AP "ap-gew4.spotify.com:4070" [2025-01-24T16:08:22Z DEBUG librespot_discovery::server] POST "/" {} [2025-01-24T16:08:52Z DEBUG librespot_discovery::server] POST "/" {} [2025-01-24T16:09:22Z DEBUG librespot_discovery::server] POST "/" {} ``` ### Host (what you are running `librespot` on): - OS: Ubuntu Desktop 22.04.5 LTS - Platform: x86_64 Dell Laptop Thanks in advance for your help. Please ask if you need more information.
kerem 2026-02-27 19:31:47 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@photovoltex commented on GitHub (Jan 24, 2025):

Seems like it's getting stuck while opening the TCP connection to the access point. I suppose you can reproduce the issue reliable?

This sounds a bit similar to #1437. Could you check your cpu usage when you run into the issue?

An just some possible ways to get it working, which don't solve the underlying issue:

<!-- gh-comment-id:2612981292 --> @photovoltex commented on GitHub (Jan 24, 2025): Seems like it's getting stuck while opening the TCP connection to the access point. I suppose you can reproduce the issue reliable? This sounds a bit similar to #1437. Could you check your cpu usage when you run into the issue? An just some possible ways to get it working, which don't solve the underlying issue: - using `oauth` instead of `zeroconf` (see https://github.com/librespot-org/librespot/wiki/Options#oauth) - or use the latest `dev` version
Author
Owner

@Timboooh commented on GitHub (Jan 24, 2025):

I think you're right thinking it's TCP:

  • CPU of librespot stays low (around min. 0.1% to max. 1.3%) when idle, shortly jumps to around 2.5% when connecting and then quickly goes back down to the same usage as the idle state. RAM usage stays low aswell.

  • Enabling OAuth doesn't seem to work (oauth.log). Using this method the player also doesn't show up in the spotify clients.

  • Using Dev branch doesn't seem to make a difference (tried both with and without oauth) (dev.log)

<!-- gh-comment-id:2613051084 --> @Timboooh commented on GitHub (Jan 24, 2025): I think you're right thinking it's TCP: - CPU of librespot stays low (around min. 0.1% to max. 1.3%) when idle, shortly jumps to around 2.5% when connecting and then quickly goes back down to the same usage as the idle state. RAM usage stays low aswell. - Enabling OAuth doesn't seem to work ([oauth.log](https://github.com/user-attachments/files/18539710/oauth.log)). Using this method the player also doesn't show up in the spotify clients. - Using Dev branch doesn't seem to make a difference (tried both with and without oauth) ([dev.log](https://github.com/user-attachments/files/18539682/dev.log))
Author
Owner

@kingosticks commented on GitHub (Jan 24, 2025):

Are you sure you don't have a firewall blocking port 4070?

<!-- gh-comment-id:2613063708 --> @kingosticks commented on GitHub (Jan 24, 2025): Are you sure you don't have a firewall blocking port 4070?
Author
Owner

@Timboooh commented on GitHub (Jan 24, 2025):

I feel stupid now, I was connected though my company's VPN which was probably blocking the TCP connections.
Disconnecting it seems to work
Sorry for taking up your time 🙃 , closing this issue

<!-- gh-comment-id:2613064663 --> @Timboooh commented on GitHub (Jan 24, 2025): I feel stupid now, I was connected though my company's VPN which was probably blocking the TCP connections. Disconnecting it seems to work Sorry for taking up your time 🙃 , closing this issue
Author
Owner

@kingosticks commented on GitHub (Jan 24, 2025):

I used to have this exact same problem when I forgot I was connected through a VPN. And I sorted it with https://github.com/librespot-org/librespot/pull/1350 but that's weirdly not helping you.

edit: maybe the connection itself is established OK but then the Spotify handshake communication is blocked - we've no timeout for that. We could add logging, or move the timeout to also include the handshake. These things should be made easier to debug.

<!-- gh-comment-id:2613069542 --> @kingosticks commented on GitHub (Jan 24, 2025): I used to have this exact same problem when I forgot I was connected through a VPN. And I sorted it with https://github.com/librespot-org/librespot/pull/1350 but that's weirdly not helping you. edit: maybe the connection itself is established OK but then the Spotify handshake communication is blocked - we've no timeout for that. We could add logging, or move the timeout to also include the handshake. These things should be made easier to debug.
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/librespot#654
No description provided.