Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI Application freezes when trying to connect #1456

Closed
Timboooh opened this issue Jan 24, 2025 · 5 comments
Closed

CLI Application freezes when trying to connect #1456

Timboooh opened this issue Jan 24, 2025 · 5 comments
Labels

Comments

@Timboooh
Copy link

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.

@Timboooh Timboooh added the bug label Jan 24, 2025
@photovoltex
Copy link
Member

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:

@Timboooh
Copy link
Author

Timboooh commented 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)

@kingosticks
Copy link
Contributor

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

@Timboooh
Copy link
Author

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

@kingosticks
Copy link
Contributor

kingosticks commented 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 #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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants