[GH-ISSUE #1547] session_connected and session_disconnected events fail to fire #701

Closed
opened 2026-02-27 19:32:02 +03:00 by kerem · 4 comments
Owner

Originally created by @samcook on GitHub (Aug 22, 2025).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/1547

Description

The session_connected and session_disconnected events fail to fire when connecting or disconnecting Spotify Connect since upgrading raspotify from 0.46.1 (which uses librespot 0.6.0 383a6f6) to 0.46.2 (which uses librespot 0.6.0-dev ba3d501). When working, this triggers some automation to power on/off my AV receiver.

Version

librespot 0.6.0-dev ba3d501 (Built on 2025-08-11, Build ID: o42TOKj2, Profile: release)

How to reproduce

  1. Launch librespot (via raspotify) with an event handler script configured.
  2. Connect with Spotify Connect.
  3. Expect session_connected event to fire, executing script which logs the event and turns on AV receiver.
  4. Disconnect Spotify Connect.
  5. Expect session_disconnected event to fire, executing script which logs the event and turns off AV receiver.

Log

Here's some (non-verbose) log of connecting then disconnecting Spotify Connect. The log lines about events firing are from my event handler script.

Aug 23 00:11:53 raspberrypi systemd[1]: Started Raspotify (Spotify Connect Client).

<establish Spotify Connect connection here>

Aug 23 00:12:31 raspberrypi librespot[13932]: [2025-08-22T12:12:31Z WARN  librespot_connect::state::context] couldn't load context info because: context is not available. type: Default
Aug 23 00:12:31 raspberrypi librespot[13959]: Event play_request_id_changed fired
Aug 23 00:12:31 raspberrypi librespot[13960]: Event loading fired
Aug 23 00:12:32 raspberrypi librespot[13961]: Event track_changed fired
Aug 23 00:12:32 raspberrypi librespot[13962]: Event paused fired
Aug 23 00:12:33 raspberrypi librespot[13962]: Published paused to raspotify/event

<disconnect Spotify Connect here>

Aug 23 00:12:48 raspberrypi librespot[13932]: [2025-08-22T12:12:48Z WARN  librespot_connect::state::context] couldn't load context info because: context is not available. type: Default
Aug 23 00:12:48 raspberrypi librespot[13932]: [2025-08-22T12:12:48Z WARN  librespot_connect::spirc] failed filling up next_track during stopping: Invalid state { context is not available. type: Default }
Aug 23 00:12:48 raspberrypi librespot[13975]: Event stopped fired
Aug 23 00:12:48 raspberrypi librespot[13975]: Published stopped to raspotify/event

The couldn't load context info because: context is not available warnings seem suspicious, and weren't happening in the previous version where things were working as expected.

There's quite a lot more logged in verbose mode which I can supply if needed.

For reference, this is what I was seeing on the previous version while doing the same actions:

Aug 22 23:55:22 raspberrypi systemd[1]: Started Raspotify (Spotify Connect Client).

<establish Spotify Connect connection here>

Aug 22 23:55:41 raspberrypi librespot[13425]: Event session_connected fired
Aug 22 23:55:41 raspberrypi librespot[13425]: Published session_connected to raspotify/event
Aug 22 23:55:41 raspberrypi librespot[13428]: Event session_client_changed fired
Aug 22 23:55:41 raspberrypi librespot[13429]: Event volume_changed fired
Aug 22 23:55:41 raspberrypi librespot[13430]: Event auto_play_changed fired
Aug 22 23:55:41 raspberrypi librespot[13431]: Event filter_explicit_content_changed fired
Aug 22 23:55:41 raspberrypi librespot[13432]: Event shuffle_changed fired
Aug 22 23:55:41 raspberrypi librespot[13433]: Event repeat_changed fired
Aug 22 23:55:41 raspberrypi librespot[13434]: Event play_request_id_changed fired
Aug 22 23:55:41 raspberrypi librespot[13435]: Event loading fired
Aug 22 23:55:41 raspberrypi librespot[13412]: [2025-08-22T11:55:41Z ERROR librespot_playback::player] Track should be available, but no alternatives found.
Aug 22 23:55:41 raspberrypi librespot[13412]: [2025-08-22T11:55:41Z WARN  librespot_playback::player] <spotify:track:1NrfYKKmddgiiHTXUdgfR5> is not available
Aug 22 23:55:41 raspberrypi librespot[13412]: [2025-08-22T11:55:41Z ERROR librespot_playback::player] Skipping to next track, unable to load track <SpotifyId("spotify:track:1NrfYKKmddgiiHTXUdgfR5")>: ()
Aug 22 23:55:41 raspberrypi librespot[13436]: Event unavailable fired
Aug 22 23:55:45 raspberrypi librespot[13412]: [2025-08-22T11:55:45Z ERROR librespot_playback::player] Unable to load audio item: Error { kind: Unavailable, error: StatusCode(500) }

<disconnect Spotify Connect here>

Aug 22 23:56:00 raspberrypi librespot[13440]: Event stopped fired
Aug 22 23:56:00 raspberrypi librespot[13440]: Published stopped to raspotify/event
Aug 22 23:56:00 raspberrypi librespot[13442]: Event session_disconnected fired
Aug 22 23:56:00 raspberrypi librespot[13442]: Published session_disconnected to raspotify/event

Host (what you are running librespot on):

  • OS: Linux
  • Platform: Raspberry Pi 4
Originally created by @samcook on GitHub (Aug 22, 2025). Original GitHub issue: https://github.com/librespot-org/librespot/issues/1547 ### Description The `session_connected` and `session_disconnected` events fail to fire when connecting or disconnecting Spotify Connect since upgrading raspotify from `0.46.1` (which uses `librespot 0.6.0 383a6f6`) to `0.46.2` (which uses `librespot 0.6.0-dev ba3d501`). When working, this triggers some automation to power on/off my AV receiver. ### Version librespot 0.6.0-dev ba3d501 (Built on 2025-08-11, Build ID: o42TOKj2, Profile: release) ### How to reproduce 1. Launch `librespot` (via `raspotify`) with an event handler script configured. 2. Connect with Spotify Connect. 3. Expect `session_connected` event to fire, executing script which logs the event and turns on AV receiver. 4. Disconnect Spotify Connect. 5. Expect `session_disconnected` event to fire, executing script which logs the event and turns off AV receiver. ### Log Here's some (non-verbose) log of connecting then disconnecting Spotify Connect. The log lines about events firing are from my event handler script. ``` Aug 23 00:11:53 raspberrypi systemd[1]: Started Raspotify (Spotify Connect Client). <establish Spotify Connect connection here> Aug 23 00:12:31 raspberrypi librespot[13932]: [2025-08-22T12:12:31Z WARN librespot_connect::state::context] couldn't load context info because: context is not available. type: Default Aug 23 00:12:31 raspberrypi librespot[13959]: Event play_request_id_changed fired Aug 23 00:12:31 raspberrypi librespot[13960]: Event loading fired Aug 23 00:12:32 raspberrypi librespot[13961]: Event track_changed fired Aug 23 00:12:32 raspberrypi librespot[13962]: Event paused fired Aug 23 00:12:33 raspberrypi librespot[13962]: Published paused to raspotify/event <disconnect Spotify Connect here> Aug 23 00:12:48 raspberrypi librespot[13932]: [2025-08-22T12:12:48Z WARN librespot_connect::state::context] couldn't load context info because: context is not available. type: Default Aug 23 00:12:48 raspberrypi librespot[13932]: [2025-08-22T12:12:48Z WARN librespot_connect::spirc] failed filling up next_track during stopping: Invalid state { context is not available. type: Default } Aug 23 00:12:48 raspberrypi librespot[13975]: Event stopped fired Aug 23 00:12:48 raspberrypi librespot[13975]: Published stopped to raspotify/event ``` The `couldn't load context info because: context is not available` warnings seem suspicious, and weren't happening in the previous version where things were working as expected. There's quite a lot more logged in verbose mode which I can supply if needed. For reference, this is what I was seeing on the previous version while doing the same actions: ``` Aug 22 23:55:22 raspberrypi systemd[1]: Started Raspotify (Spotify Connect Client). <establish Spotify Connect connection here> Aug 22 23:55:41 raspberrypi librespot[13425]: Event session_connected fired Aug 22 23:55:41 raspberrypi librespot[13425]: Published session_connected to raspotify/event Aug 22 23:55:41 raspberrypi librespot[13428]: Event session_client_changed fired Aug 22 23:55:41 raspberrypi librespot[13429]: Event volume_changed fired Aug 22 23:55:41 raspberrypi librespot[13430]: Event auto_play_changed fired Aug 22 23:55:41 raspberrypi librespot[13431]: Event filter_explicit_content_changed fired Aug 22 23:55:41 raspberrypi librespot[13432]: Event shuffle_changed fired Aug 22 23:55:41 raspberrypi librespot[13433]: Event repeat_changed fired Aug 22 23:55:41 raspberrypi librespot[13434]: Event play_request_id_changed fired Aug 22 23:55:41 raspberrypi librespot[13435]: Event loading fired Aug 22 23:55:41 raspberrypi librespot[13412]: [2025-08-22T11:55:41Z ERROR librespot_playback::player] Track should be available, but no alternatives found. Aug 22 23:55:41 raspberrypi librespot[13412]: [2025-08-22T11:55:41Z WARN librespot_playback::player] <spotify:track:1NrfYKKmddgiiHTXUdgfR5> is not available Aug 22 23:55:41 raspberrypi librespot[13412]: [2025-08-22T11:55:41Z ERROR librespot_playback::player] Skipping to next track, unable to load track <SpotifyId("spotify:track:1NrfYKKmddgiiHTXUdgfR5")>: () Aug 22 23:55:41 raspberrypi librespot[13436]: Event unavailable fired Aug 22 23:55:45 raspberrypi librespot[13412]: [2025-08-22T11:55:45Z ERROR librespot_playback::player] Unable to load audio item: Error { kind: Unavailable, error: StatusCode(500) } <disconnect Spotify Connect here> Aug 22 23:56:00 raspberrypi librespot[13440]: Event stopped fired Aug 22 23:56:00 raspberrypi librespot[13440]: Published stopped to raspotify/event Aug 22 23:56:00 raspberrypi librespot[13442]: Event session_disconnected fired Aug 22 23:56:00 raspberrypi librespot[13442]: Published session_disconnected to raspotify/event ``` ### Host (what you are running `librespot` on): - OS: Linux - Platform: Raspberry Pi 4
kerem 2026-02-27 19:32:02 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@roderickvd commented on GitHub (Aug 23, 2025):

@photovoltex @kingosticks or other community members: any takers for this one? This may be a regression relevant to streaming distros that we don’t want in v0.7.

<!-- gh-comment-id:3216467401 --> @roderickvd commented on GitHub (Aug 23, 2025): @photovoltex @kingosticks or other community members: any takers for this one? This may be a regression relevant to streaming distros that we don’t want in v0.7.
Author
Owner

@photovoltex commented on GitHub (Aug 23, 2025):

I could maybe look later in the evening. And btw. what is considered a connect and disconnect? Does this mean when the device becomes the active one and when it loses it. Or is it related to when we start up and shutdown?

<!-- gh-comment-id:3216501550 --> @photovoltex commented on GitHub (Aug 23, 2025): I could maybe look later in the evening. And btw. what is considered a connect and disconnect? Does this mean when the device becomes the active one and when it loses it. Or is it related to when we start up and shutdown?
Author
Owner

@roderickvd commented on GitHub (Aug 23, 2025):

That’d be great ❤️ It’s when a user connects or disconnects: https://github.com/librespot-org/librespot/wiki/Events. In dealer parlance I guess this is equivalent to becoming or stopping to be the active device.

<!-- gh-comment-id:3216547251 --> @roderickvd commented on GitHub (Aug 23, 2025): That’d be great ❤️ It’s when a user connects or disconnects: https://github.com/librespot-org/librespot/wiki/Events. In dealer parlance I guess this is equivalent to becoming or stopping to be the active device.
Author
Owner

@photovoltex commented on GitHub (Aug 23, 2025):

For the connect I can confirm that it doesn't run through the usual start playing branch, which results that the event doesn't seem to be fired when we connect and isn't fired again when we try to play or load anything because we are already the active device. For the disconnect I can also confirm but didn't look to much into it. Should be easy to fix, I will give you a PR later on.

<!-- gh-comment-id:3217244372 --> @photovoltex commented on GitHub (Aug 23, 2025): For the connect I can confirm that it doesn't run through the usual start playing branch, which results that the event doesn't seem to be fired when we connect and isn't fired again when we try to play or load anything because we are already the active device. For the disconnect I can also confirm but didn't look to much into it. Should be easy to fix, I will give you a PR later on.
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#701
No description provided.