node-sonos-http-api icon indicating copy to clipboard operation
node-sonos-http-api copied to clipboard

500 error when attempting to start Spotify artist radio via musicsearch

Open obliojoe opened this issue 5 years ago • 4 comments
trafficstars

When I try to play Spotify artist radio, I am getting a 500 error.

URL: http://localhost:5005/kitchen/musicsearch/spotify/station/wilco

Response: Error: Got status 500 when invoking /MediaRenderer/AVTransport/Control at Object.invoke (D:\dev\sonos\node-sonos-http-api\node_modules\sonos-discovery\lib\helpers\soap.js:99:10) at Player.play (D:\dev\sonos\node-sonos-http-api\node_modules\sonos-discovery\lib\models\Player.js:446:15) at D:\dev\sonos\node-sonos-http-api\lib\actions\musicSearch.js:229:44 at processTicksAndRejections (internal/process/task_queues.js:97:5)

I am able to call other musicsearch endpoints.

These both work: /musicsearch/spotify/song/wilco /musicsearch/spotify/album/wilco

And I can start Spotify artist radio manually from the Sonos app.

Any thoughts?

obliojoe avatar Sep 12 '20 16:09 obliojoe

Interestingly, if I have the Sonos app open on my computer when I make this call, the app displays the error:

Unable to play 'Wilco Radio' - the connection to Spotify was lost.

obliojoe avatar Sep 12 '20 16:09 obliojoe

Update: I used Wireshark to see what my Sonos app sends when I start Spotify artist radio and compared it to what the API is sending. The only difference was:

Sonos: x-sonosapi-radio:spotify%3aartistRadio%3a2QoU3awHVdcHS8LrZEKvSM?sid=12&flags=8300&sn=1 API: x-sonosapi-radio:spotify%3aartistRadio%3a2QoU3awHVdcHS8LrZEKvSM?sid=12&flags=8300&sn=14

The only difference was sn=14.

I found line 50 of musicsearch.js: https://github.com/jishi/node-sonos-http-api/blob/7b5d5e45863a4ea88a34aab3e554e282ab93b945/lib/music_services/spotifyDef.js#L149

If I change that to 1, everything seems to work as expected.

obliojoe avatar Sep 13 '20 07:09 obliojoe

I don't remember what the sn-parameters refers to, and if it now differs between systems it needs to be discovered somehow. obviously someone changed this at some point, and I haven't used this music search api myself (it was contributed). If you find any more info about this, please share it.

jishi avatar Sep 13 '20 08:09 jishi

@obliojoe tangentially off topic, but would you be able to share the process for using wireshark to sniff the Sonos traffic? I had a go with it earlier but couldn't seem to isolate it, but this would be very helpful in my efforts to bring the Deezer implementation up to date! Thank you

mochi-co avatar Jan 05 '21 21:01 mochi-co