[GH-ISSUE #125] Do we need always to select the "go-librespot" device in Spotify client? #74

Closed
opened 2026-02-28 14:25:08 +03:00 by kerem · 4 comments
Owner

Originally created by @lnkpaulo on GitHub (Oct 18, 2024).
Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/125

Hello,

I cloned the latest version and ran it with my config.xml which is setup as follows:

device_name: go-librespot
credentials:
  type: interactive
server:
  enabled: true
  port: 3678

After going through the authentication process, I see:

INFO[0000] api server listening on 127.0.0.1:3678       
INFO[0000] authenticated AP as xxxxxxxxxx               
INFO[0000] authenticated Login5 as xxxxxxxxxx    

I then open my Spotify client on my mobile device, select the device named 'go-librespot,' and I can successfully play music.
I also have a server/client connected to go-librespot:3678, which works.

Here's where the strange behavior occurs:
When I drop the server go-librespot:3678, the Spotify client on my mobile loses the connection, which is expected.

Now I restart the server at go-librespot:3678, I get the following logs:

INFO[0000] api server listening on 127.0.0.1:3678       
INFO[0000] authenticated AP as xxxxxxxxxx               
INFO[0000] authenticated Login5 as xxxxxxxxxx    

... so far, so good. However, when I try to play music again using my server/client, nothing happens. To make it work, I need to reopen the Spotify client on my mobile, reconnect to the 'go-librespot' device, and then everything works as expected.

In conclusion, do I always need to open the Spotify client on my mobile and reconnect to 'go-librespot' for my server/client to work? This wasn't necessary in previous versions when the username/password authentication was still supported.

For your reference my server/client setup:
go-librespot:3678 <--> FastAPIServer (with my state-machine) <--> React Client

Thank you for the support.

Originally created by @lnkpaulo on GitHub (Oct 18, 2024). Original GitHub issue: https://github.com/devgianlu/go-librespot/issues/125 Hello, I cloned the latest version and ran it with my `config.xml` which is setup as follows: ```yml device_name: go-librespot credentials: type: interactive server: enabled: true port: 3678 ``` After going through the authentication process, I see: ``` INFO[0000] api server listening on 127.0.0.1:3678 INFO[0000] authenticated AP as xxxxxxxxxx INFO[0000] authenticated Login5 as xxxxxxxxxx ``` I then open my Spotify client on my mobile device, select the device named 'go-librespot,' and I can successfully play music. I also have a server/client connected to `go-librespot:3678`, which works. Here's where the strange behavior occurs: When I drop the server `go-librespot:3678`, the Spotify client on my mobile loses the connection, which is expected. Now I restart the server at `go-librespot:3678`, I get the following logs: ``` INFO[0000] api server listening on 127.0.0.1:3678 INFO[0000] authenticated AP as xxxxxxxxxx INFO[0000] authenticated Login5 as xxxxxxxxxx ``` ... so far, so good. However, when I try to play music again using my server/client, nothing happens. To make it work, I need to reopen the Spotify client on my mobile, reconnect to the 'go-librespot' device, and then everything works as expected. In conclusion, do I always need to open the Spotify client on my mobile and reconnect to 'go-librespot' for my server/client to work? This wasn't necessary in previous versions when the username/password authentication was still supported. For your reference my server/client setup: _go-librespot:3678 <--> FastAPIServer (with my state-machine) <--> React Client_ Thank you for the support.
kerem closed this issue 2026-02-28 14:25:09 +03:00
Author
Owner

@devgianlu commented on GitHub (Oct 20, 2024):

However, when I try to play music again using my server/client, nothing happens.

I suppose you are referring to starting playback through the API. Which request are you making to the API?

<!-- gh-comment-id:2424869214 --> @devgianlu commented on GitHub (Oct 20, 2024): > However, when I try to play music again using my server/client, nothing happens. I suppose you are referring to starting playback through the API. Which request are you making to the API?
Author
Owner

@lnkpaulo commented on GitHub (Oct 20, 2024):

I'm doing this:

DEBUG - 2024-10-20 16:47:40,843 - fastapi_app -  url: http://localhost:3678/player/resume Sending payload uri='spotify:track:0bL5tco8cV95q5FNFzxzUS' skip_to_uri=None paused=False

... I think the issue is related with the "resume" in my state machine when I drop the go-librespot.

Let me check in more detail and I will return to you.

<!-- gh-comment-id:2425061479 --> @lnkpaulo commented on GitHub (Oct 20, 2024): I'm doing this: ``` DEBUG - 2024-10-20 16:47:40,843 - fastapi_app - url: http://localhost:3678/player/resume Sending payload uri='spotify:track:0bL5tco8cV95q5FNFzxzUS' skip_to_uri=None paused=False ``` ... I think the issue is related with the "resume" in my state machine when I drop the go-librespot. Let me check in more detail and I will return to you.
Author
Owner

@lnkpaulo commented on GitHub (Oct 20, 2024):

... Yes the issue is with the resume, if the "go-librespot" is running the resume works, but if I drop it and start it again the resume is not working. which makes sense if "go-librespot" is keeping a session.

Only for your reference I need to change the logic of my current endpoint :

@router.post("/player/play")
async def play(payload: PlayPayload):
    current_state = state_machine.get_current_state()
    logger.debug(f"Current State: {current_state}")
    url = RESUME if current_state.status == "pause" else PLAY

    async with httpx.AsyncClient() as client:
        logger.debug(f"url: {url} Sending payload {payload}")
        response = await client.post(url, json=payload.dict())
    return await handle_response(response, "Play command executed without response body")

and improve the state machine to identify if go-librespot went down and then up.

So if my reasoning is ok, I think we can close this issue.
Thank you for your time.

<!-- gh-comment-id:2425097992 --> @lnkpaulo commented on GitHub (Oct 20, 2024): ... Yes the issue is with the resume, if the "go-librespot" is running the resume works, but if I drop it and start it again the resume is not working. which makes sense if "go-librespot" is keeping a session. Only for your reference I need to change the logic of my current endpoint : ```python @router.post("/player/play") async def play(payload: PlayPayload): current_state = state_machine.get_current_state() logger.debug(f"Current State: {current_state}") url = RESUME if current_state.status == "pause" else PLAY async with httpx.AsyncClient() as client: logger.debug(f"url: {url} Sending payload {payload}") response = await client.post(url, json=payload.dict()) return await handle_response(response, "Play command executed without response body") ``` and improve the state machine to identify if go-librespot went down and then up. So if my reasoning is ok, I think we can close this issue. Thank you for your time.
Author
Owner

@devgianlu commented on GitHub (Oct 20, 2024):

Glad you figured out the problem!

<!-- gh-comment-id:2425118611 --> @devgianlu commented on GitHub (Oct 20, 2024): Glad you figured out the problem!
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/go-librespot#74
No description provided.