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

Slow to connect to Librespot #1394

Open
YutongGu opened this issue Nov 14, 2024 · 9 comments
Open

Slow to connect to Librespot #1394

YutongGu opened this issue Nov 14, 2024 · 9 comments
Labels

Comments

@YutongGu
Copy link

YutongGu commented Nov 14, 2024

Description

When connecting to librespot, the application hangs for up to 33 seconds before successfully establishing a connection and appearing within the Spotify Connect app

Version

The latest build of the dev branch (82076e8). Built with flags --features alsa-backend --features with-dns-sd

How to reproduce

Steps to reproduce the behavior in librespot e.g.

  1. Launch librespot with cargo run -- -n test1 --zeroconf-port 10000
  2. Launch another librespot instance with cargo run -- --n test2 --zeroconf-port 10001
  3. Connect to 'test1' with Spotify App on iOS
  4. Connect to 'test2' with the Spotify App on iOS
  5. See that the 'connecting' message appears and the app hangs for several seconds

Log

cargo run -- -n test1 -v
    Finished dev [unoptimized + debuginfo] target(s) in 0.36s
     Running `target/debug/librespot -n test1 -v
[2024-11-14T01:13:07Z INFO  librespot] librespot 0.6.0-dev 82076e8 (Built on 2024-11-14, Build ID: pELpeF2F, Profile: debug)
[2024-11-14T01:13:07Z TRACE librespot] Command line argument(s):
[2024-11-14T01:13:07Z TRACE librespot] 		n "test1"
[2024-11-14T01:13:07Z TRACE librespot] 		v
[2024-11-14T01:13:07Z DEBUG librespot_core::session] new Session
[2024-11-14T01:13:07Z DEBUG librespot_discovery::server] Zeroconf server listening on 0.0.0.0:32973
[2024-11-14T01:13:07Z INFO  librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Log(60.0)
[2024-11-14T01:13:07Z DEBUG librespot_playback::player] new Player [0]
[2024-11-14T01:13:07Z INFO  librespot_playback::convert] Converting with ditherer: tpdf
[2024-11-14T01:13:07Z INFO  librespot_playback::audio_backend::rodio] Using Rodio sink with format S16 and cpal host: ALSA
[2024-11-14T01:13:07Z INFO  librespot_playback::audio_backend::rodio] Using audio device: default
[2024-11-14T01:13:07Z DEBUG librespot_playback::audio_backend::rodio] Rodio sink was created
[2024-11-14T01:13:14Z DEBUG librespot_discovery::server] POST "/" {}
[2024-11-14T01:13:14Z DEBUG librespot_core::session] Shutdown: Invalidating session
[2024-11-14T01:13:14Z DEBUG librespot::component] new MercuryManager
[2024-11-14T01:13:14Z DEBUG librespot::component] new ChannelManager
[2024-11-14T01:13:14Z DEBUG librespot_core::session] new Session
[2024-11-14T01:13:14Z DEBUG librespot_connect::spirc] new Spirc[0]
[2024-11-14T01:13:14Z DEBUG librespot::component] new MercuryManager
[2024-11-14T01:13:14Z DEBUG librespot::component] new SpClient
[2024-11-14T01:13:14Z DEBUG librespot_playback::player] command=SetSession
[2024-11-14T01:13:14Z DEBUG librespot_core::spclient] Client token unavailable or expired, requesting new token.
[2024-11-14T01:13:14Z DEBUG librespot_core::session] drop Session
[2024-11-14T01:13:14Z DEBUG librespot::component] drop ChannelManager
[2024-11-14T01:13:14Z DEBUG librespot::component] drop MercuryManager
[2024-11-14T01:13:14Z DEBUG librespot_core::http_client] Requesting https://clienttoken.spotify.com/v1/clienttoken
[2024-11-14T01:13:15Z DEBUG librespot_core::spclient] Received a granted token
[2024-11-14T01:13:15Z TRACE librespot_core::spclient] Got client token: GrantedTokenResponse { token: "AAAKY+P3Z633R0nDYcXhITCS8Je6CFv3VBCRY9q1DTD9XgMtGrFLLbASkQVK1/IloIqn9Hxw1GLDZrGGSMMy1pa0PRU1dM0aYq5lySlT8bNJK538mP8jCDoeYYxXB3Ax5I0WWtzmx71UycA5NIBtbqJ0iVuLeChtVCJZNOe+ZSQt0jhB2puVbYu2+TuTkbatdb25lZ4zNJmXV8vdDtX4J0syTj64AAEoMNqSwLmNKx4Fz2RPqTOs6mPFQmfgugPWWAgsDQvKA+zWocZNg2maVZM8Hc87PxO41t3ViL8ztfs/eQsz4t45ed1W3qm9iyBAWqIW8xRSnAjVi4r1pzbXbao=", 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 } } }
[2024-11-14T01:13:15Z DEBUG librespot::component] new ApResolver
[2024-11-14T01:13:15Z DEBUG librespot_core::http_client] Requesting https://apresolve.spotify.com/?type=accesspoint&type=dealer&type=spclient
[2024-11-14T01:13:15Z INFO  librespot_core::session] Connecting to AP "ap-guc3.spotify.com:4070"
[2024-11-14T01:13:15Z DEBUG librespot_core::connection] Authenticating with AP using AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS
[2024-11-14T01:13:15Z INFO  librespot_core::session] Authenticated as '1219828745' !
[2024-11-14T01:13:15Z DEBUG librespot_connect::spirc] canonical_username: 1219828745
[2024-11-14T01:13:15Z DEBUG librespot_playback::mixer::mappings] Input volume 58958 mapped to: 49.99%
[2024-11-14T01:13:15Z DEBUG librespot_playback::player] command=AddEventSender
[2024-11-14T01:13:15Z DEBUG librespot_core::mercury] listening to uri=hm://remote/user/
[2024-11-14T01:13:15Z DEBUG librespot_core::mercury] listening to uri=spotify:user:attributes:update
[2024-11-14T01:13:15Z DEBUG librespot_core::mercury] listening to uri=spotify:user:attributes:mutated
[2024-11-14T01:13:15Z DEBUG librespot_core::mercury] listening to uri=hm://pusher/v1/connections/
[2024-11-14T01:13:15Z TRACE librespot_core::session] Received Ping
[2024-11-14T01:13:15Z TRACE librespot_core::session] keep-alive state: PendingPong, timeout in 60.0
[2024-11-14T01:13:15Z DEBUG librespot_core::session] Session strong=4 weak=5
[2024-11-14T01:13:15Z INFO  librespot_core::session] Country: "US"
[2024-11-14T01:13:15Z TRACE librespot_core::session] Received product info: {
        "enable-annotations-read": "0",
        "enable-gapless": "1",
        "key-caching-max-offline-seconds": "1800",
        "ab-browse-music-tuesday": "1",
        "ab-collection-offline-mode": "0",
        "head-file-caching": "1",
        "unrestricted": "1",
        "publish-activity": "0",
        "ab-android-push-notifications": "1",
        "key-caching-max-count": "10000",
        "fb-grant-permission-local-render": "0",
        "capping-bar-threshold": "3601",
        "use-playlist-uris": "0",
        "local-files-import": "0",
        "ad-session-persistence": "1",
        "browse-overview-enabled": "1",
        "buffering-strategy": "0",
        "enable-crossfade": "1",
        "filter-explicit-content": "0",
        "ugc-abuse-report": "1",
        "ugc-abuse-report-url": "https://support.spotify.com/abuse/?uri={uri}",
        "shows-collection-jam": "1",
        "ab-mobile-social-feed": "1",
        "ab-test-group": "398",
        "restrict-playlist-collaboration": "0",
        "prefetch-keys": "1",
        "video-manifest-url": "https://spclient.wg.spotify.com/manifests/v6/{type}/sources/{source_id}/options/supports_drm",
        "high-bitrate": "1",
        "collection": "1",
        "type": "premium",
        "offline": "1",
        "profile-image-upload": "1",
        "ab-moments-experience": "0",
        "widevine-license-url": "https://spclient.wg.spotify.com/widevine-license/v1/video/license",
        "audiobook-onboarding-completed": "0",
        "playlist-folders": "1",
        "ab-collection-union": "1",
        "backend-advised-bitrate": "1",
        "loudness-levels": "1:-5.0,0.0,3.0:-2.0",
        "ads": "0",
        "fb-info-confirmation": "control",
        "explicit-content": "1",
        "ab_recently_played_feature_time_filter_threshold": "com.spotify.gaia=30,driving-mode=120,spotify%3Ainternal%3Astartpage=30",
        "mobile": "1",
        "on-demand": "1",
        "key-memory-cache-mode": "1:15,300",
        "send-email": "0",
        "ab-ad-player-targeting": "1",
        "ab-desktop-playlist-annotation-edit": "1",
        "mobile-payment": "0",
        "head-files": "1",
        "playlist-annotations-markup": "0",
        "prefetch-window-max": "2",
        "shuffle-algorithm": "1",
        "payments-initial-campaign": "default",
        "instant-search-expand-sidebar": "0",
        "is_maybe_in_social_session": "0",
        "video-cdn-sampling": "1",
        "use-playlist-app": "0",
        "ab-playlist-extender": "5",
        "public-toplist": "7",
        "head-files-url": "https://heads-fa-tls13.spotifycdn.com/head/{file_id}",
        "image-url": "https://i.scdn.co/image/{file_id}",
        "pause-after": "0",
        "use-pl3": "0",
        "nft-disabled": "1",
        "ab-collection-hide-unavailable-albums": "0",
        "ab-desktop-hide-follow": "0",
        "ab-mobile-running-tempo-detection": "Control",
        "ab-play-history": "0",
        "ad-formats-preroll-video": "0",
        "ad-formats-video-takeover": "1",
        "ab-mobile-startpage": "0",
        "audio-quality": "1",
        "remote-control": "6",
        "shuffle": "0",
        "app-developer": "0",
        "video-keyframe-url": "http://keyframes-fa.cdn.spotify.com/keyframes/v1/sources/{source_id}/keyframe/heights/{height}/timestamps/{timestamp_ms}.jpg",
        "ab-new-share-flow": "0",
        "audiobook-onboarding-dismissed": "0",
        "arsenal_country": "1",
        "license-acceptance-grace-days": "30",
        "india-experience": "0",
        "player-license": "premium",
        "preferred-locale": "en-us",
        "key-caching-auto-offline": "0",
        "shows-collection": "1",
        "user-profile-show-invitation-codes": "0",
        "financial-product": "pr:premium,tc:0,rt:v2_US_hulu-premium-otc_hulu-premium-otc-1m_11.99_USD_default",
        "ab-collection-followed-artists-only": "0",
        "payments-locked-state": "0",
        "sidebar-navigation-enabled": "0",
        "video-wifi-initial-bitrate": "800000",
        "mobile-login": "1",
        "ab-mobile-running-onlymanualmode": "only-manual",
        "streaming": "1",
        "ap-resolve-pods": "0",
        "expiry": "1",
        "buffering-strategy-parameters": "0.8:0.2:0.0:0.0:0.0:0.0:1.0:10:10:2000:10000:10485760",
        "rating-access": "1",
        "enable-annotations": "2",
        "ab-ad-requester": "1",
        "instant-search": "0",
        "publish-playlist": "1",
        "metadata-link-lookup-modes": "0",
        "autoplay": "1",
        "is_email_verified": "1",
        "ab-watch-now": "0",
        "video-initial-bitrate": "200000",
        "allow-override-internal-prefs": "0",
        "network-operator-premium-activation": "1",
        "audio-preview-url-template": "https://p.scdn.co/mp3-preview/{id}",
        "name": "Spotify Premium",
        "ab-collection-bookmark-model": "1",
        "ad-persist-reward-time": "0",
        "catalogue": "premium",
        "prefetch-strategy": "18",
        "ab-mobile-discover": "0",
        "employee-free-opt-in": "0",
        "incognito_mode_timeout": "21600",
        "use-fb-publish-backend": "2",
        "mobile-browse": "0",
        "storage-size-config": "10240,90,500,3",
        "libspotify": "1",
        "video-device-blacklisted": "0",
        "enable-autostart": "1",
        "track-cap": "0",
        "radio": "1",
    }
[2024-11-14T01:13:15Z TRACE librespot_connect::spirc] Received connection ID update: "YjQ0NGFjMDY2MTNmYzhkNjM3OTViZTlhZDBiZWFmNTUwMTE5MzZhYytBUCt0Y3A6Ly8wYWNiZGEwYi5pcC5ndWMzLnNwb3RpZnkubmV0OjUwMTgrNkNDMEY0RjdFOTc5REM1RTVBQjUzMkVBMjc0NTNDMUFCQkYxRTE2OEU0NEM5OEYxQzlCMzIxNEJCRjE4ODNBMA%3D%3D"
[2024-11-14T01:13:15Z DEBUG librespot::component] new Login5Manager
[2024-11-14T01:13:15Z DEBUG librespot_core::http_client] Requesting https://login5.spotify.com/v3/login
[2024-11-14T01:13:15Z TRACE librespot_core::login5] Got auth token: Token { access_token: "BQCVX7KFNjzH3yI1s_i9vLE40QoSj8k2S2UMVdKwGVAYIvCFDzYknxzG_JQb_crNo53vOAy-B2Em6owE2yYbnzZTdpx2ayo4rakcE6Pcv8hxkL1vLjB5i9fZIMAZBNm-gSq7goL3Vb7oT0wgVKW5kKQouQemF6Z55vB3iTc6q25lxy7-lZEjNNhAosWYYdzZrUBystO8NpeeoM7ku8jl2NkrCixPAtQI0CpisrjiQsFdrrt7-KD9T1HJx1JcQfieWih2n5j8MCoudDKB19SniVxoYGmpuqZlEqTh5HMwV7lT30Hh0OPm2YonlrlTAjgv2pvRFmZhJc17IW6OV_k0JAUZzExe-dDoAbKsOtXm42KTng", expires_in: 3600s, token_type: "Bearer", scopes: [], timestamp: Instant { tv_sec: 96962, tv_nsec: 883180898 } }
[2024-11-14T01:13:15Z DEBUG librespot_connect::spirc] successfully pre-acquire access_token and client_token


[2024-11-14T01:13:47Z DEBUG librespot_discovery::server] POST "/" {}
[2024-11-14T01:13:47Z DEBUG librespot_core::session] Shutdown: Invalidating session
[2024-11-14T01:13:47Z DEBUG librespot::component] new ChannelManager
[2024-11-14T01:13:47Z DEBUG librespot_core::session] new Session
[2024-11-14T01:13:47Z DEBUG librespot_connect::spirc] new Spirc[1]
[2024-11-14T01:13:47Z DEBUG librespot::component] new MercuryManager
[2024-11-14T01:13:47Z DEBUG librespot::component] new SpClient
[2024-11-14T01:13:47Z DEBUG librespot_playback::player] command=SetSession
[2024-11-14T01:13:47Z DEBUG librespot_core::spclient] Client token unavailable or expired, requesting new token.
[2024-11-14T01:13:47Z DEBUG librespot_core::http_client] Requesting https://clienttoken.spotify.com/v1/clienttoken
[2024-11-14T01:13:47Z ERROR librespot_connect::spirc] user attributes mutation selected, but none received
[2024-11-14T01:13:47Z DEBUG librespot_connect::spirc] drop Spirc[0]
[2024-11-14T01:13:47Z DEBUG librespot_core::session] drop Session
[2024-11-14T01:13:47Z DEBUG librespot::component] drop ApResolver
[2024-11-14T01:13:47Z DEBUG librespot::component] drop ChannelManager
[2024-11-14T01:13:47Z DEBUG librespot::component] drop MercuryManager
[2024-11-14T01:13:47Z DEBUG librespot::component] drop SpClient
[2024-11-14T01:13:47Z DEBUG librespot::component] drop Login5Manager
[2024-11-14T01:13:47Z DEBUG librespot_core::session] drop Dispatch
[2024-11-14T01:13:53Z DEBUG librespot_core::spclient] Received a granted token
[2024-11-14T01:13:53Z TRACE librespot_core::spclient] Got client token: GrantedTokenResponse { token: "AACEH1vPR6P6gsg+KXFDrYGRtdHQnzML5lPFLOIrAU24AeiMzuECQtsg7+3JZVJbjITkwuKNdTd4p/OAQ2SUDuBZmHg5LgqC/lDilngK5nhk7gmwMaDJ4AOkS58Z9BZiJOagmUIT8QyIe04AWDM2cbNASYKdY9BRdrcynV4ufergOHRRNlCLxJuZyqcHBv1v8CmC+TAGBYfVZELfO4JZx5EKDiz3Ck//MRdCmydmTjG/8bBqvydYe8ZiBJkRJsBTDh2IH7efmiw8fv+F/7uDfhCYMvLFWZ31Bc/vb/5QC3r8M8ysh7xtQbbX4nyynfz+6ELhnLbxR0kMo1fHV+XN+LU=", 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 } } }
[2024-11-14T01:13:53Z DEBUG librespot::component] new ApResolver
[2024-11-14T01:13:53Z DEBUG librespot_core::http_client] Requesting https://apresolve.spotify.com/?type=accesspoint&type=dealer&type=spclient
[2024-11-14T01:13:53Z INFO  librespot_core::session] Connecting to AP "ap-guc3.spotify.com:4070"
[2024-11-14T01:13:53Z DEBUG librespot_core::connection] Authenticating with AP using AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS
[2024-11-14T01:13:53Z INFO  librespot_core::session] Authenticated as '1219828745' !
[2024-11-14T01:13:53Z DEBUG librespot_connect::spirc] canonical_username: 1219828745
[2024-11-14T01:13:53Z DEBUG librespot_playback::mixer::mappings] Input volume 58958 mapped to: 49.99%
[2024-11-14T01:13:53Z DEBUG librespot_playback::player] command=AddEventSender
[2024-11-14T01:13:53Z DEBUG librespot_core::mercury] listening to uri=hm://pusher/v1/connections/
[2024-11-14T01:13:53Z DEBUG librespot_core::mercury] listening to uri=hm://remote/user/
[2024-11-14T01:13:53Z DEBUG librespot_core::mercury] listening to uri=spotify:user:attributes:update
[2024-11-14T01:13:53Z DEBUG librespot_core::mercury] listening to uri=spotify:user:attributes:mutated
[2024-11-14T01:13:53Z TRACE librespot_core::session] Received Ping
[2024-11-14T01:13:53Z TRACE librespot_core::session] keep-alive state: PendingPong, timeout in 60.0
[2024-11-14T01:13:53Z DEBUG librespot_core::session] Session strong=4 weak=5
[2024-11-14T01:13:53Z INFO  librespot_core::session] Country: "US"
[2024-11-14T01:13:53Z TRACE librespot_core::session] Received product info: {
        "ab-browse-music-tuesday": "1",
        "ab-ad-requester": "1",
        "ugc-abuse-report-url": "https://support.spotify.com/abuse/?uri={uri}",
        "financial-product": "pr:premium,tc:0,rt:v2_US_hulu-premium-otc_hulu-premium-otc-1m_11.99_USD_default",
        "ab-mobile-running-tempo-detection": "Control",
        "ab-watch-now": "0",
        "storage-size-config": "10240,90,500,3",
        "send-email": "0",
        "ad-persist-reward-time": "0",
        "ab-collection-followed-artists-only": "0",
        "name": "Spotify Premium",
        "ab-android-push-notifications": "1",
        "fb-info-confirmation": "control",
        "rating-access": "1",
        "audio-quality": "1",
        "buffering-strategy-parameters": "0.8:0.2:0.0:0.0:0.0:0.0:1.0:10:10:2000:10000:10485760",
        "head-file-caching": "1",
        "mobile": "1",
        "image-url": "https://i.scdn.co/image/{file_id}",
        "use-fb-publish-backend": "2",
        "instant-search-expand-sidebar": "0",
        "license-acceptance-grace-days": "30",
        "loudness-levels": "1:-5.0,0.0,3.0:-2.0",
        "on-demand": "1",
        "key-caching-max-count": "10000",
        "profile-image-upload": "1",
        "video-cdn-sampling": "1",
        "is_maybe_in_social_session": "0",
        "enable-crossfade": "1",
        "public-toplist": "7",
        "publish-activity": "0",
        "local-files-import": "0",
        "mobile-browse": "0",
        "enable-annotations-read": "0",
        "network-operator-premium-activation": "1",
        "capping-bar-threshold": "3601",
        "widevine-license-url": "https://spclient.wg.spotify.com/widevine-license/v1/video/license",
        "india-experience": "0",
        "ab-new-share-flow": "0",
        "mobile-login": "1",
        "ad-formats-video-takeover": "1",
        "allow-override-internal-prefs": "0",
        "ab-mobile-discover": "0",
        "key-caching-auto-offline": "0",
        "browse-overview-enabled": "1",
        "ab-ad-player-targeting": "1",
        "preferred-locale": "en-us",
        "backend-advised-bitrate": "1",
        "libspotify": "1",
        "high-bitrate": "1",
        "offline": "1",
        "shuffle": "0",
        "enable-annotations": "2",
        "restrict-playlist-collaboration": "0",
        "shows-collection-jam": "1",
        "head-files-url": "https://heads-fa-tls13.spotifycdn.com/head/{file_id}",
        "filter-explicit-content": "0",
        "ab-collection-bookmark-model": "1",
        "shows-collection": "1",
        "audiobook-onboarding-dismissed": "0",
        "prefetch-strategy": "18",
        "ab-playlist-extender": "5",
        "audiobook-onboarding-completed": "0",
        "video-initial-bitrate": "200000",
        "ab-test-group": "398",
        "track-cap": "0",
        "arsenal_country": "1",
        "shuffle-algorithm": "1",
        "ab-collection-hide-unavailable-albums": "0",
        "payments-initial-campaign": "default",
        "nft-disabled": "1",
        "explicit-content": "1",
        "collection": "1",
        "fb-grant-permission-local-render": "0",
        "video-manifest-url": "https://spclient.wg.spotify.com/manifests/v6/{type}/sources/{source_id}/options/supports_drm",
        "pause-after": "0",
        "ab-mobile-social-feed": "1",
        "app-developer": "0",
        "mobile-payment": "0",
        "payments-locked-state": "0",
        "autoplay": "1",
        "employee-free-opt-in": "0",
        "ap-resolve-pods": "0",
        "catalogue": "premium",
        "ugc-abuse-report": "1",
        "ab-moments-experience": "0",
        "prefetch-window-max": "2",
        "ab-collection-offline-mode": "0",
        "player-license": "premium",
        "ab-mobile-running-onlymanualmode": "only-manual",
        "radio": "1",
        "buffering-strategy": "0",
        "ab-desktop-playlist-annotation-edit": "1",
        "is_email_verified": "1",
        "key-caching-max-offline-seconds": "1800",
        "use-pl3": "0",
        "audio-preview-url-template": "https://p.scdn.co/mp3-preview/{id}",
        "streaming": "1",
        "ab-mobile-startpage": "0",
        "head-files": "1",
        "video-device-blacklisted": "0",
        "video-keyframe-url": "http://keyframes-fa.cdn.spotify.com/keyframes/v1/sources/{source_id}/keyframe/heights/{height}/timestamps/{timestamp_ms}.jpg",
        "unrestricted": "1",
        "ad-formats-preroll-video": "0",
        "playlist-folders": "1",
        "sidebar-navigation-enabled": "0",
        "ad-session-persistence": "1",
        "ab-play-history": "0",
        "prefetch-keys": "1",
        "type": "premium",
        "metadata-link-lookup-modes": "0",
        "remote-control": "6",
        "expiry": "1",
        "ads": "0",
        "instant-search": "0",
        "key-memory-cache-mode": "1:15,300",
        "user-profile-show-invitation-codes": "0",
        "video-wifi-initial-bitrate": "800000",
        "ab-collection-union": "1",
        "incognito_mode_timeout": "21600",
        "enable-autostart": "1",
        "use-playlist-app": "0",
        "ab_recently_played_feature_time_filter_threshold": "com.spotify.gaia=30,driving-mode=120,spotify%3Ainternal%3Astartpage=30",
        "enable-gapless": "1",
        "ab-desktop-hide-follow": "0",
        "use-playlist-uris": "0",
        "publish-playlist": "1",
        "playlist-annotations-markup": "0",
    }
[2024-11-14T01:13:53Z TRACE librespot_connect::spirc] Received update frame: Frame {
        version: Some(
            1,
        ),
        ident: Some(
            "007cee7429a834514fa218dbf6efbedce142a66b",
        ),
        protocol_version: Some(
            "2.0.0",
        ),
        seq_nr: Some(
            675014618,
        ),
        typ: Some(
            kMessageTypeNotify,
        ),
        device_state: MessageField(
            Some(
                DeviceState {
                    sw_version: Some(
                        "0.5.0-dev",
                    ),
                    is_active: Some(
                        false,
                    ),
                    can_play: Some(
                        true,
                    ),
                    volume: Some(
                        19660,
                    ),
                    name: Some(
                        "Zone 5",
                    ),
                    error_code: None,
                    became_active_at: None,
                    error_message: None,
                    capabilities: [
                        Capability {
                            typ: Some(
                                kCanBePlayer,
                            ),
                            intValue: [
                                1,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kRestrictToLocal,
                            ),
                            intValue: [
                                0,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kGaiaEqConnectId,
                            ),
                            intValue: [
                                1,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kSupportsLogout,
                            ),
                            intValue: [
                                0,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kIsObservable,
                            ),
                            intValue: [
                                1,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kCommandAcks,
                            ),
                            intValue: [
                                0,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kSupportsRename,
                            ),
                            intValue: [
                                1,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kHidden,
                            ),
                            intValue: [
                                0,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kDeviceType,
                            ),
                            intValue: [
                                4,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kVolumeSteps,
                            ),
                            intValue: [
                                64,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kSupportsPlaylistV2,
                            ),
                            intValue: [
                                1,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kSupportsExternalEpisodes,
                            ),
                            intValue: [
                                1,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kSupportedTypes,
                            ),
                            intValue: [],
                            stringValue: [
                                "audio/episode",
                                "audio/episode+track",
                                "audio/track",
                            ],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                    ],
                    context_player_error: None,
                    metadata: [],
                    special_fields: SpecialFields {
                        unknown_fields: UnknownFields {
                            fields: None,
                        },
                        cached_size: CachedSize {
                            size: 0,
                        },
                    },
                },
            ),
        ),
        goodbye: MessageField(
            None,
        ),
        state: MessageField(
            None,
        ),
        position: None,
        volume: None,
        state_update_id: Some(
            1731546834100,
        ),
        recipient: [],
        context_player_state: None,
        new_name: None,
        metadata: MessageField(
            None,
        ),
        special_fields: SpecialFields {
            unknown_fields: UnknownFields {
                fields: None,
            },
            cached_size: CachedSize {
                size: 0,
            },
        },
    }
[2024-11-14T01:13:53Z TRACE librespot_connect::spirc] Sending status to server: [kPlayStatusStop]
[2024-11-14T01:13:53Z TRACE librespot_connect::spirc] Received connection ID update: "YjQ0NGFjMDY2MTNmYzhkNjM3OTViZTlhZDBiZWFmNTUwMTE5MzZhYytBUCt0Y3A6Ly8wYWNiZDkyYi5pcC5ndWMzLnNwb3RpZnkubmV0OjUwMDcrMkE5MUJFRUYxRjM5MDM1QjU5M0RDNkRDODIxMTU0NDA0QUQzNzM4Rjc0QjMyMDlEMjc3QTM0QkFBNEUyOTMzMQ%3D%3D"
[2024-11-14T01:13:53Z DEBUG librespot::component] new Login5Manager
[2024-11-14T01:13:53Z DEBUG librespot_core::http_client] Requesting https://login5.spotify.com/v3/login
[2024-11-14T01:13:54Z TRACE librespot_core::login5] Got auth token: Token { access_token: "BQAdIq4a-qWwP0QKhT66-hJD3x_wIJv0d6GQ-SOmGTFMWoJF0ewjYoLiX0RPiSfyJ3NTliinXIN-GsAV0xgBKyICvJf02UJOUg0jQ2ZEUgYkXpOo6_GAjW0YjV1WV1fbXdZIM-ZEeV3tkYkCXG1T-VUTUcBbahCxA9OXePcUvytdpP9VCgm2FIS7WtGVVfWS_6I3Ch8x0ccvEkwMpHc_jNXj8ejIexjPNGfFS3ELFnKv5Rm4hq0Ru7uN-0reufMhZ9PzQiAXtES64jTuGuueNW88ML9IfWB9wHeE5GmmoAc2vmaMb5Mb7PLMlHbj2-mQL38sw4LOhIwDcGq7NEm9_VhOKbUga6JafWGhIqDRvDlZbw", expires_in: 3600s, token_type: "Bearer", scopes: [], timestamp: Instant { tv_sec: 97001, tv_nsec: 278407806 } }
[2024-11-14T01:13:54Z DEBUG librespot_connect::spirc] successfully pre-acquire access_token and client_token
[2024-11-14T01:13:54Z TRACE librespot_connect::spirc] Received update frame: Frame {
        version: Some(
            1,
        ),
        ident: Some(
            "408f526f-bff2-4e01-a3b0-99e1d687276d",
        ),
        protocol_version: Some(
            "2.0.0",
        ),
        seq_nr: Some(
            675014618,
        ),
        typ: Some(
            kMessageTypeNotify,
        ),
        device_state: MessageField(
            Some(
                DeviceState {
                    sw_version: Some(
                        "esdk:3.203.235-g416668ac/track-playback",
                    ),
                    is_active: Some(
                        false,
                    ),
                    can_play: Some(
                        true,
                    ),
                    volume: Some(
                        26214,
                    ),
                    name: Some(
                        "408f526f-bff2-4e01-a3b0-99e1d687276d",
                    ),
                    error_code: None,
                    became_active_at: None,
                    error_message: None,
                    capabilities: [
                        Capability {
                            typ: Some(
                                kCanBePlayer,
                            ),
                            intValue: [
                                1,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kRestrictToLocal,
                            ),
                            intValue: [
                                0,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kGaiaEqConnectId,
                            ),
                            intValue: [
                                1,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kSupportsLogout,
                            ),
                            intValue: [
                                1,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kIsObservable,
                            ),
                            intValue: [
                                1,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kCommandAcks,
                            ),
                            intValue: [
                                1,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kSupportsRename,
                            ),
                            intValue: [
                                0,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kHidden,
                            ),
                            intValue: [
                                0,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kDeviceType,
                            ),
                            intValue: [
                                4,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kVolumeSteps,
                            ),
                            intValue: [
                                16,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kSupportsPlaylistV2,
                            ),
                            intValue: [
                                0,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kSupportsExternalEpisodes,
                            ),
                            intValue: [
                                1,
                            ],
                            stringValue: [],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Capability {
                            typ: Some(
                                kSupportedTypes,
                            ),
                            intValue: [],
                            stringValue: [
                                "audio/track",
                                "audio/episode",
                                "audio/dj",
                            ],
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                    ],
                    context_player_error: None,
                    metadata: [
                        Metadata {
                            type_: Some(
                                "client_id",
                            ),
                            metadata: Some(
                                "27d4dfe427b34d57995b463e5d63198d",
                            ),
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Metadata {
                            type_: Some(
                                "brand_display_name",
                            ),
                            metadata: Some(
                                "Amazon",
                            ),
                            special_fields: SpecialFields {
                                unknown_fields: UnknownFields {
                                    fields: None,
                                },
                                cached_size: CachedSize {
                                    size: 0,
                                },
                            },
                        },
                        Metadata {
                            type_: Some(
                                "model_display_name",
                            ),
                            metadata: Some(
                                "Echo_Dot",
                            ),
                            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,
                        },
                    },
                },
            ),
        ),
        goodbye: MessageField(
            None,
        ),
        state: MessageField(
            None,
        ),
        position: None,
        volume: None,
        state_update_id: Some(
            1731546834100,
        ),
        recipient: [],
        context_player_state: None,
        new_name: None,
        metadata: MessageField(
            None,
        ),
        special_fields: SpecialFields {
            unknown_fields: UnknownFields {
                fields: None,
            },
            cached_size: CachedSize {
                size: 0,
            },
        },
    }
[2024-11-14T01:13:54Z TRACE librespot_connect::spirc] Sending status to server: [kPlayStatusStop]
[2024-11-14T01:13:54Z TRACE librespot_connect::spirc] Received update frame: Frame {

Host (what you are running librespot on):

  • OS: Linux Ubuntu 20.04
  • Platform: Lenovo T14

Additional context

@YutongGu YutongGu added the bug label Nov 14, 2024
@YutongGu
Copy link
Author

YutongGu commented Nov 14, 2024

Update: It appears that this appears to be more of a problem when there are multiple librespot instances on the same network and you switch from one to the other or you attempt to connect to a new instance after disconnecting from another. I will update this post as I learn more.

@ashthespy
Copy link
Member

You might also want to run it with the --release flag to rule out something trivial like slowdowns from debug builds

@YutongGu
Copy link
Author

YutongGu commented Nov 16, 2024

I'm running with the --release flag but I'm still having issues. It seems like when changing from connecting to one librespot instance to another is problematic. It seems to hang for a while and occasionally you'll have both librespot instances playing simultaneously but out of sync when moving from one connection to another.

Can anyone else reproduce this?

@YutongGu
Copy link
Author

It seems like this may have something to do with the fact that even when disconnecting the spotify app from the device, the session with the spotify server is never actually closed.

I'm seeing that even when switching connection from one librespot instance to another, the previous instance continues to send data to the server when pausing/playing to the newly connected librespot instance.

I can also get it to quickly switch from one connection to another by keyboard interrupting the first instance aright after starting a connection attempt to a second instance.

@roderickvd
Copy link
Member

I've seen other reports of librespot disconnects not being picked up properly in the current code base.

Though it's experimental, could you take #1356 for a spin? If the new dealer API fixes it then I'd say to focus our efforts there rather than on the current spirc API.

@photovoltex
Copy link
Contributor

photovoltex commented Nov 17, 2024

A friend of mine tried out the dealer branch and seemed to have run into this problem using discovery/zeroconf while first connecting. Afterwards (without caching) it was instant tho. So might not have to do something with the spirc/dealer and is maybe more a discovery problem? I didn't look into it myself tho, so it might also be an entirely different topic.

@YutongGu
Copy link
Author

YutongGu commented Nov 19, 2024

I just took #1356 for a spin and it's still slow to switch connections between multiple librespot instances but it's much better about handling disconnecting and reconnecting from a single librespot instance.

I'm curious why we keep the session and mercury subscriptions alive even after a client has disconnected from a spotify client. Is this for caching purposes? Could cause spotify's servers to delay new connections from librespot instances as it waits for a previous connection to close?

Strike all that, I was on the wrong branch. #1356 solves this problem entirely for me!

@YutongGu
Copy link
Author

YutongGu commented Nov 19, 2024

Great work on this! Changing connections is pretty seemless now. The only problem though is that when switching from connecting to one librespot instance to another, something goes wrong and my phone fails to establish the new connection and it will drop all previous connection. The easy workaround is to try again and that usually works.

@photovoltex Is that something you're aware of?

EDIT: Another thing I noticed was that it would sometimes go back to a previous song when switching connections from one librespot instance to another. I'm having trouble reproducing it now but it did happen once.

@photovoltex
Copy link
Contributor

The only problem though is that when switching from connecting to one librespot instance to another, something goes wrong and my phone fails to establish the new connection and it will drop all previous connection.

So far i only tested with a single instance and never tried transferring from one librespot instance to another. A bummer that it doesn't work out of the box, but probably has something to do with the initial transfer handling.

EDIT: Another thing I noticed was that it would sometimes go back to a previous song when switching connections from one librespot instance to another. I'm having trouble reproducing it now but it did happen once.

yeah, sometimes it does resolve some positions incorrectly. didn't figure out what it triggers yet tho

but yeah the branch still has some problems here and there, the general usage should be given but some edge cases i personally don't used that often are not fully covered/tested yet.

Anyhow, if you have any other issues, ideas or trouble with the branch, we should probably continuing it on #1356 itself. Any feedback, testing or issue reporting on the state is welcome :D

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

4 participants