Repository: aome510/spotify-player (language: rust)

Issue:
Player crash on wifi connection change (activating/deactivating vpn)
**Describe the bug**
When a VPN connection (WireGuard in my case) is activated/deactivated I get a player crash after some time that I cannot recover without restarting the application.

**To Reproduce**
Start playing music through spotify_player, then activate or deactivate a VPN connection, wait for some time for the progress bar to run through.

**Expected behavior**
The player should continue playing.

**Log and backtrace**
backtrace file is empty.
```
2024-02-09T11:40:51.777842Z  INFO spotify_player: General configurations: AppConfig { theme: "dracula", client_id: "REDACTED", client_port: 8080, copy_command: Command { command: "xclip", args: ["-sel", "c"] }, player_event_hook_command: None, playback_format: "{track} • {artists}\n{album}\n{metadata}", notify_format: NotifyFormat { summary: "{track} • {artists}", body: "{album}" }, tracks_playback_limit: 50, proxy: None, ap_port: None, app_refresh_duration_in_ms: 32, playback_refresh_duration_in_ms: 0, cover_image_refresh_duration_in_ms: 2000, page_size_in_rows: 20, play_icon: "▶", pause_icon: "▌▌", liked_icon: "♥", border_type: Plain, progress_bar_type: Rectangle, playback_window_position: Top, cover_img_length: 9, cover_img_width: 5, cover_img_scale: 1.0, playback_window_width: 6, enable_media_control: true, enable_streaming: Always, enable_cover_image_cache: true, default_device: "spotify-player", device: DeviceConfig { name: "spotify-player", device_type: "speaker", volume: 70, bitrate: 320, audio_cache: false, normalization: false } }
2024-02-09T11:40:51.777980Z  INFO spotify_player: Theme configurations: ThemeConfig { themes: [Theme { name: "default", palette: Palette { background: None, foreground: None, black: Color { color: Black }, blue: Color { color: LightBlue }, cyan: Color { color: LightCyan }, green: Color { color: LightGreen }, magenta: Color { color: LightMagenta }, red: Color { color: LightRed }, white: Color { color: Gray }, yellow: Color { color: LightYellow }, bright_black: Color { color: DarkGray }, bright_white: Color { color: White }, bright_red: Color { color: Red }, bright_magenta: Color { color: Magenta }, bright_green: Color { color: Green }, bright_cyan: Color { color: Cyan }, bright_blue: Color { color: Blue }, bright_yellow: Color { color: Yellow } }, component_style: ComponentStyle { block_title: None, border: None, playback_track: None, playback_artists: None, playback_album: None, playback_metadata: None, playback_progress_bar: None, current_playing: None, page_desc: None, table_header: None, selection: None } }] }
2024-02-09T11:40:51.778003Z  INFO spotify_player: Keymap configurations: KeymapConfig { keymaps: [Keymap { key_sequence: KeySequence { keys: [None(Char('n'))] }, command: NextTrack }, Keymap { key_sequence: KeySequence { keys: [None(Char('p'))] }, command: PreviousTrack }, Keymap { key_sequence: KeySequence { keys: [None(Char('.'))] }, command: PlayRandom }, Keymap { key_sequence: KeySequence { keys: [None(Char(' '))] }, command: ResumePause }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('r'))] }, command: Repeat }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('s'))] }, command: Shuffle }, Keymap { key_sequence: KeySequence { keys: [None(Char('+'))] }, command: VolumeUp }, Keymap { key_sequence: KeySequence { keys: [None(Char('-'))] }, command: VolumeDown }, Keymap { key_sequence: KeySequence { keys: [None(Char('_'))] }, command: Mute }, Keymap { key_sequence: KeySequence { keys: [None(Char('>'))] }, command: SeekForward }, Keymap { key_sequence: KeySequence { keys: [None(Char('<'))] }, command: SeekBackward }, Keymap { key_sequence: KeySequence { keys: [None(Enter)] }, command: ChooseSelected }, Keymap { key_sequence: KeySequence { keys: [None(Char('r'))] }, command: RefreshPlayback }, Keymap { key_sequence: KeySequence { keys: [None(Char('/'))] }, command: Search }, Keymap { key_sequence: KeySequence { keys: [None(Char('z'))] }, command: Queue }, Keymap { key_sequence: KeySequence { keys: [None(Char('Z'))] }, command: AddSelectedItemToQueue }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char(' '))] }, command: ShowActionsOnSelectedItem }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('a'))] }, command: ShowActionsOnSelectedItem }, Keymap { key_sequence: KeySequence { keys: [None(Char('a'))] }, command: ShowActionsOnCurrentTrack }, Keymap { key_sequence: KeySequence { keys: [None(Char('R'))] }, command: RestartIntegratedClient }, Keymap { key_sequence: KeySequence { keys: [None(Tab)] }, command: FocusNextWindow }, Keymap { key_sequence: KeySequence { keys: [None(BackTab)] }, command: FocusPreviousWindow }, Keymap { key_sequence: KeySequence { keys: [None(Char('T'))] }, command: SwitchTheme }, Keymap { key_sequence: KeySequence { keys: [None(Char('D'))] }, command: SwitchDevice }, Keymap { key_sequence: KeySequence { keys: [None(Char('u')), None(Char('p'))] }, command: BrowseUserPlaylists }, Keymap { key_sequence: KeySequence { keys: [None(Char('u')), None(Char('a'))] }, command: BrowseUserFollowedArtists }, Keymap { key_sequence: KeySequence { keys: [None(Char('u')), None(Char('A'))] }, command: BrowseUserSavedAlbums }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char(' '))] }, command: CurrentlyPlayingContextPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('t'))] }, command: TopTrackPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('r'))] }, command: RecentlyPlayedTrackPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('y'))] }, command: LikedTrackPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('L'))] }, command: LyricPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('l'))] }, command: LyricPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('l'))] }, command: LibraryPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('s'))] }, command: SearchPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('b'))] }, command: BrowsePage }, Keymap { key_sequence: KeySequence { keys: [None(Backspace)] }, command: PreviousPage }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('q'))] }, command: PreviousPage }, Keymap { key_sequence: KeySequence { keys: [None(Char('?'))] }, command: OpenCommandHelp }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('h'))] }, command: OpenCommandHelp }, Keymap { key_sequence: KeySequence { keys: [None(Char('q'))] }, command: Quit }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('c'))] }, command: Quit }, Keymap { key_sequence: KeySequence { keys: [None(Esc)] }, command: ClosePopup }, Keymap { key_sequence: KeySequence { keys: [None(Char('j'))] }, command: SelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('n'))] }, command: SelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [None(Down)] }, command: SelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [None(Char('k'))] }, command: SelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('p'))] }, command: SelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [None(Up)] }, command: SelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [None(PageUp)] }, command: PageSelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('b'))] }, command: PageSelectPreviousOrScrollUp }, Keymap { key_sequence: KeySequence { keys: [None(PageDown)] }, command: PageSelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('f'))] }, command: PageSelectNextOrScrollDown }, Keymap { key_sequence: KeySequence { keys: [None(Char('g')), None(Char('g'))] }, command: SelectFirstOrScrollToTop }, Keymap { key_sequence: KeySequence { keys: [None(Home)] }, command: SelectFirstOrScrollToTop }, Keymap { key_sequence: KeySequence { keys: [None(Char('G'))] }, command: SelectLastOrScrollToBottom }, Keymap { key_sequence: KeySequence { keys: [None(End)] }, command: SelectLastOrScrollToBottom }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('t'))] }, command: SortTrackByTitle }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('a'))] }, command: SortTrackByArtists }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('A'))] }, command: SortTrackByAlbum }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('d'))] }, command: SortTrackByDuration }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('D'))] }, command: SortTrackByAddedDate }, Keymap { key_sequence: KeySequence { keys: [None(Char('s')), None(Char('r'))] }, command: ReverseTrackOrder }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('k'))] }, command: MovePlaylistItemUp }, Keymap { key_sequence: KeySequence { keys: [Ctrl(Char('j'))] }, command: MovePlaylistItemDown }] }
2024-02-09T11:40:53.006822Z  INFO spotify_player::auth: Successfully used the cached credentials to create a new session!
2024-02-09T11:40:53.189360Z  INFO spotify_player::token: Getting new authentication token...
2024-02-09T11:40:53.395090Z  INFO spotify_player::token: Got new token: Token { access_token: "REDACTED", expires_in: Duration { secs: 3600, nanos: 0 }, expires_at: Some(2024-02-09T12:40:53.395081999Z), refresh_token: None, scopes: {} }
2024-02-09T11:40:53.395178Z  INFO spotify_player::streaming: Application's connect configurations: ConnectConfig { name: "spotify-player", device_type: Speaker, initial_volume: Some(45875), has_volume_ctrl: true, autoplay: false }
2024-02-09T11:40:53.395215Z  INFO spotify_player::streaming: Initializing a new integrated player with device_id=REDACTED
2024-02-09T11:40:53.395331Z  INFO spotify_player::streaming: Starting an integrated Spotify player using librespot's spirc protocol
2024-02-09T11:40:53.654685Z  INFO spotify_player: No playback found on startup, trying to connect to an available device...
2024-02-09T11:40:53.654883Z  INFO spotify_player::cli::client: Starting a client socket at 127.0.0.1:8080
2024-02-09T11:40:53.655277Z  INFO spotify_player::media_control: Initializing application's media control event watcher...
2024-02-09T11:40:53.855519Z  INFO client_request{request=GetCurrentUser}: spotify_player::client: successfully handled the client request, took: 200ms
2024-02-09T11:40:54.027523Z  INFO client_request{request=GetUserPlaylists}: spotify_player::client: successfully handled the client request, took: 372ms
2024-02-09T11:40:54.237305Z  INFO client_request{request=GetUserFollowedArtists}: spotify_player::client: successfully handled the client request, took: 582ms
2024-02-09T11:40:54.701152Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: Available devices: []
2024-02-09T11:40:54.701206Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: Trying to connect to device (id=REDACTED)
2024-02-09T11:40:54.985414Z  INFO client_request{request=GetUserSavedAlbums}: spotify_player::client: successfully handled the client request, took: 1330ms
2024-02-09T11:40:55.274755Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: Connection succeeded (device_id=REDACTED)!
2024-02-09T11:40:55.274837Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: successfully handled the client request, took: 1619ms
2024-02-09T11:40:56.495405Z  INFO spotify_player::client: Retrieving an image from the file: /home/REDACTED/.cache/spotify-player/image/new day-dLira-cover.jpg
2024-02-09T11:40:56.495620Z  INFO spotify_player::client: Retrieving an image from the file: /home/REDACTED/.cache/spotify-player/image/new day-dLira-cover.jpg
2024-02-09T11:40:57.869743Z  INFO spotify_player::streaming: Got a new player event: Paused { track_id: TrackId("3TfYxNREMvcFuL4cmgAJHj"), position_ms: 426, duration_ms: 138666 }
2024-02-09T11:40:57.917518Z  INFO client_request{request=Player(ResumePause)}: spotify_player::client: successfully handled the client request, took: 276ms
2024-02-09T11:40:58.014319Z  INFO spotify_player::streaming: Got a new player event: Playing { track_id: TrackId("3TfYxNREMvcFuL4cmgAJHj"), position_ms: 426, duration_ms: 138666 }
2024-02-09T11:40:58.014800Z  INFO spotify_player::streaming: Got a new player event: Playing { track_id: TrackId("3TfYxNREMvcFuL4cmgAJHj"), position_ms: 426, duration_ms: 138666 }
2024-02-09T11:40:58.074416Z  INFO client_request{request=GetCurrentPlayback}: spotify_player::client: successfully handled the client request, took: 204ms
2024-02-09T11:40:58.224899Z  INFO client_request{request=GetCurrentPlayback}: spotify_player::client: successfully handled the client request, took: 210ms
2024-02-09T11:40:58.266732Z  INFO client_request{request=GetUserSavedTracks}: spotify_player::client: successfully handled the client request, took: 4611ms
2024-02-09T11:40:58.285811Z  INFO client_request{request=GetCurrentPlayback}: spotify_player::client: successfully handled the client request, took: 270ms
```

**Screenshots**
![screenshot-20240209-124328](https://github.com/aome510/spotify-player/assets/76734819/29c59154-92b3-4ad6-9d42-6c35ae990721)

**Environment**

- OS: NixOS 23.11 (stable)
- Application version: spotify_player 0.15.2
- Application features: sixel, notify, streaming, image, lyrics, mediacontrol, daemon, audio backend rodio [If I undertand the flake correctly](https://github.com/NixOS/nixpkgs/blob/nixos-23.11/pkgs/applications/audio/spotify-player/default.nix#L95)

**Additional context**
I also had this problem before on EndeavourOS on both my Laptop and my PC. The recommended action in the screenshot does not work, as no device show up when executing SwitchDevice.

Ill be glad to supply more information when needed.


Discussion / hints:
> When a VPN connection (WireGuard in my case) is activated/deactivated I get a player crash after some time that I cannot recover without restarting the application.

WDYM in terms of crashing? Does the whole app crashes or just the client not working while UI is still rendering? 

Network issue can cause the client to be in an "invalid" state. When network is back, it takes time for the client to recover by itself. You can force restarting the client by invoking `RestartIntegratedClient` command (`R` shortcut).

> I also had this problem before on EndeavourOS on both my Laptop and my PC. The recommended action in the screenshot does not work, as no device show up when executing SwitchDevice.

The message is outdated because of the old version. The new one will include more detailed instruction. I suspect it's because you haven't set up **Spotify Connect** support.

> No playback found. Please make sure there is a running Spotify device and try to connect to one using the `SwitchDevice` command. You may also need to set up Spotify Connect to see available devices as in https://github.com/aome510/spotify-player#spotify-connect.

I reproduced this in 0.16.3. For me:

>WDYM in terms of crashing? Does the whole app crashes or just the client not working while UI is still rendering?

The UI keeps working, it's just it doesn't continue to play any music after the current track ends. Keeps the end-of-song screen and after a while goes to the "No playback found" screen you cited. Besides that, it seems there is no network functionality at all - Playlist screens stay loading and the search menu doesn't show any results.

>You can force restarting the client by invoking RestartIntegratedClient command (R shortcut).

I actually haven't managed to get it working again with this, even after waiting a few minutes
> I reproduced this in 0.16.3. For me:
> 
> > WDYM in terms of crashing? Does the whole app crashes or just the client not working while UI is still rendering?
> 
> The UI keeps working, it's just it doesn't continue to play any music after the current track ends. Keeps the end-of-song screen and after a while goes to the "No playback found" screen you cited. Besides that, it seems there is no network functionality at all - Playlist screens stay loading and the search menu doesn't show any results.
> 
> > You can force restarting the client by invoking RestartIntegratedClient command (R shortcut).
> 
> I actually haven't managed to get it working again with this, even after waiting a few minutes

Can you share another log of that not working run with `RestartIntegratedClient`?
There it goes:
<details><pre><code>2024-02-12T23:55:54.715519Z  INFO spotify_player::streaming: Application's connect configurations: ConnectConfig { name: "Omen-Pop", device_type: Speaker, initial_volume: Some(45875), has_volume_ctrl: true, autoplay: false }
2024-02-12T23:55:54.715542Z  INFO spotify_player::streaming: Initializing a new integrated player with device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29
2024-02-12T23:55:54.715628Z  INFO spotify_player::streaming: Starting an integrated Spotify player using librespot's spirc protocol
2024-02-12T23:55:54.988103Z  INFO spotify_player: No playback found on startup, trying to connect to an available device...
2024-02-12T23:55:54.988412Z  INFO spotify_player: Starting a client socket at 127.0.0.1:8080
2024-02-12T23:55:54.989260Z  INFO spotify_player::media_control: Initializing application's media control event watcher...
2024-02-12T23:55:55.078282Z  INFO client_request{request=GetCurrentUser}: spotify_player::client: successfully handled the client request, took: 89ms
2024-02-12T23:55:55.445835Z  INFO client_request{request=GetUserPlaylists}: spotify_player::client: successfully handled the client request, took: 457ms
2024-02-12T23:55:56.056544Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: Available devices: []
2024-02-12T23:55:56.056623Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:55:56.301004Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: Connection succeeded (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)!
2024-02-12T23:55:56.301040Z  INFO client_request{request=ConnectDevice(None)}: spotify_player::client: successfully handled the client request, took: 1312ms
2024-02-12T23:55:56.379007Z  INFO client_request{request=GetUserFollowedArtists}: spotify_player::client: successfully handled the client request, took: 1390ms
2024-02-12T23:55:56.781385Z  INFO spotify_player::streaming: Got a new player event: Paused { track_id: TrackId("0A4BbWRwXcLmpkiyfOXjpr"), position_ms: 11670, duration_ms: 150375 }
2024-02-12T23:55:56.795126Z  INFO client_request{request=GetUserSavedAlbums}: spotify_player::client: successfully handled the client request, took: 1806ms
2024-02-12T23:55:56.868917Z  INFO client_request{request=GetCurrentPlayback}: spotify_player::client: successfully handled the client request, took: 87ms
2024-02-12T23:55:57.713103Z ERROR client_request{request=Player(ResumePause)}: spotify_player::client::handlers: Failed to handle client request: no playback found
2024-02-12T23:55:58.657678Z  INFO spotify_player::client: Retrieving an image from the file: /home/lucasfa/.cache/spotify-player/image/Grace-Ax and the Hatchetmen-cover.jpg
2024-02-12T23:56:00.839286Z  INFO spotify_player::streaming: Got a new player event: Playing { track_id: TrackId("0A4BbWRwXcLmpkiyfOXjpr"), position_ms: 11670, duration_ms: 150375 }
2024-02-12T23:56:00.840242Z  INFO spotify_player::streaming: Got a new player event: Playing { track_id: TrackId("0A4BbWRwXcLmpkiyfOXjpr"), position_ms: 11670, duration_ms: 150375 }
2024-02-12T23:56:00.844345Z  INFO client_request{request=Player(ResumePause)}: spotify_player::client: successfully handled the client request, took: 307ms
2024-02-12T23:56:01.121834Z  INFO client_request{request=GetCurrentPlayback}: spotify_player::client: successfully handled the client request, took: 281ms
2024-02-12T23:56:01.129680Z  INFO client_request{request=GetCurrentPlayback}: spotify_player::client: successfully handled the client request, took: 290ms
2024-02-12T23:56:03.114374Z  INFO client_request{request=GetUserSavedTracks}: spotify_player::client: successfully handled the client request, took: 8125ms
2024-02-12T23:56:15.763839Z ERROR spotify_player::client: Encountered an error when updating the playback state: http error: request: request or response body error: operation timed out
2024-02-12T23:56:19.697301Z ERROR client_request{request=Player(NextTrack)}: spotify_player::client::handlers: Failed to handle client request: http error: request: error sending request for url (https://api.spotify.com/v1/me/player/next?device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): operation timed out
2024-02-12T23:56:26.767329Z ERROR spotify_player::client: Encountered an error when updating the playback state: http error: request: error sending request for url (https://api.spotify.com/v1/me/player): operation timed out
2024-02-12T23:56:39.558970Z  INFO client_request{request=NewStreamingConnection}: spotify_player::streaming: Application's connect configurations: ConnectConfig { name: "Omen-Pop", device_type: Speaker, initial_volume: Some(45875), has_volume_ctrl: true, autoplay: false }
2024-02-12T23:56:39.559072Z  INFO client_request{request=NewStreamingConnection}: spotify_player::streaming: Initializing a new integrated player with device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29
2024-02-12T23:56:39.559202Z  INFO client_request{request=NewStreamingConnection}: spotify_player::streaming: Starting an integrated Spotify player using librespot's spirc protocol
2024-02-12T23:56:40.559777Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:56:50.561039Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: request: error sending request for url (https://api.spotify.com/v1/me/player): operation timed out
2024-02-12T23:56:51.562038Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:56:51.964848Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Connection succeeded (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)!
2024-02-12T23:56:51.964929Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: successfully handled the client request, took: 12405ms
2024-02-12T23:56:53.656189Z ERROR client_request{request=Player(ResumePause)}: spotify_player::client::handlers: Failed to handle client request: http error: request: error sending request for url (https://api.spotify.com/v1/me/player/pause?device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): operation timed out
2024-02-12T23:57:52.289018Z ERROR client_request{request=Player(ResumePause)}: spotify_player::client::handlers: Failed to handle client request: no playback found
2024-02-12T23:57:55.442341Z ERROR client_request{request=Player(ResumePause)}: spotify_player::client::handlers: Failed to handle client request: no playback found
2024-02-12T23:57:57.726054Z ERROR client_request{request=Player(ResumePause)}: spotify_player::client::handlers: Failed to handle client request: no playback found
2024-02-12T23:58:00.638747Z ERROR client_request{request=Player(ResumePause)}: spotify_player::client::handlers: Failed to handle client request: no playback found
2024-02-12T23:58:00.922353Z ERROR client_request{request=Player(ResumePause)}: spotify_player::client::handlers: Failed to handle client request: no playback found
2024-02-12T23:59:35.558307Z  INFO client_request{request=NewStreamingConnection}: spotify_player::streaming: Application's connect configurations: ConnectConfig { name: "Omen-Pop", device_type: Speaker, initial_volume: Some(45875), has_volume_ctrl: true, autoplay: false }
2024-02-12T23:59:35.558447Z  INFO client_request{request=NewStreamingConnection}: spotify_player::streaming: Initializing a new integrated player with device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29
2024-02-12T23:59:35.558521Z  INFO client_request{request=NewStreamingConnection}: spotify_player::streaming: Starting an integrated Spotify player using librespot's spirc protocol
2024-02-12T23:59:36.560008Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:37.028276Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:38.028808Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:38.340440Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:39.342702Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:39.724289Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:40.724988Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:41.035196Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:42.036384Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:42.352562Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:43.354056Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:43.664353Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:44.664856Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:44.975584Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:45.976953Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:46.288777Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:47.289718Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:47.600992Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:48.601827Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:48.960775Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:48.960861Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: successfully handled the client request, took: 13402ms
2024-02-12T23:59:52.377273Z  INFO client_request{request=NewStreamingConnection}: spotify_player::streaming: Application's connect configurations: ConnectConfig { name: "Omen-Pop", device_type: Speaker, initial_volume: Some(45875), has_volume_ctrl: true, autoplay: false }
2024-02-12T23:59:52.377383Z  INFO client_request{request=NewStreamingConnection}: spotify_player::streaming: Initializing a new integrated player with device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29
2024-02-12T23:59:52.377500Z  INFO client_request{request=NewStreamingConnection}: spotify_player::streaming: Starting an integrated Spotify player using librespot's spirc protocol
2024-02-12T23:59:53.379077Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:53.691555Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:54.693218Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:55.006312Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:56.006957Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:56.322559Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:57.324829Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:57.661483Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:58.662862Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-12T23:59:58.974713Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-12T23:59:59.975714Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-13T00:00:00.291406Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-13T00:00:01.292381Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)
2024-02-13T00:00:01.608550Z  WARN client_request{request=NewStreamingConnection}: spotify_player::client: Connection failed (device_id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29): http error: status code 404 Not Found
2024-02-13T00:00:02.610026Z  INFO client_request{request=NewStreamingConnection}: spotify_player::client: Trying to connect to device (id=2908bd92-2ad6-4ee7-80a8-96f8b7bdcb29)</code></pre>
</details>

Fix patch:
diff --git a/spotify_player/src/client/mod.rs b/spotify_player/src/client/mod.rs
index 2fcbbe05..9e74366a 100644
--- a/spotify_player/src/client/mod.rs
+++ b/spotify_player/src/client/mod.rs
@@ -253,10 +253,8 @@ impl Client {
                 self.connect_device(state, id).await;
             }
             #[cfg(feature = "streaming")]
-            ClientRequest::NewStreamingConnection => {
-                let device_id = self.new_streaming_connection(state).await;
-                // upon creating a new streaming connection, connect to it
-                self.connect_device(state, Some(device_id)).await;
+            ClientRequest::RestartIntegratedClient => {
+                self.new_session(state).await?;
             }
             ClientRequest::GetCurrentUser => {
                 let user = self.spotify.current_user().await?;
diff --git a/spotify_player/src/event/mod.rs b/spotify_player/src/event/mod.rs
index 1daa34a1..51a57bc6 100644
--- a/spotify_player/src/event/mod.rs
+++ b/spotify_player/src/event/mod.rs
@@ -76,7 +76,7 @@ pub enum ClientRequest {
         artists: String,
     },
     #[cfg(feature = "streaming")]
-    NewStreamingConnection,
+    RestartIntegratedClient,
 }
 
 /// starts a terminal event handler (key pressed, mouse clicked, etc)
@@ -444,7 +444,7 @@ fn handle_global_command(
         }
         #[cfg(feature = "streaming")]
         Command::RestartIntegratedClient => {
-            client_pub.send(ClientRequest::NewStreamingConnection)?;
+            client_pub.send(ClientRequest::RestartIntegratedClient)?;
         }
         Command::FocusNextWindow => {
             if !ui.has_focused_popup() {


Test patch: