jishi / node-sonos-http-api

An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.
http://jishi.github.io/node-sonos-http-api/
MIT License
1.84k stars 461 forks source link

MusicSearch Adding Songs to Queue, but returning error #422

Open crbender opened 7 years ago

crbender commented 7 years ago

When issuing: /living room/musicsearch/apple/song/closer

Sonos Status: Playing an Apple Music Radio Station

Error Received: {"status":"error","error":"Got status 500 when invoking /MediaRenderer/AVTransport/Control","stack":"Error\n at Object.invoke (/home/user/node-sonos-http-api-old/node-sonos-http-api/node_modules/sonos-discovery/lib/helpers/soap.js:95:10)\n at Player.setAVTransport (/home/user/node-sonos-http-api-old/node-sonos-http-api/node_modules/sonos-discovery/lib/models/Player.js:651:15)\n at player.coordinator.getQueue.then.then.then (/home/user/node-sonos-http-api-old/node-sonos-http-api/lib/actions/musicSearch.js:265:47)\n at process._tickDomainCallback (internal/process/next_tick.js:129:7)"}

OS: 16.04.1 LTS Node: v6.9.2

Note: MusicSearch is working when there are items in the queue and it's in use, but the error above seems to be returned when playing anything not from the queue (Apple Music Radio, TuneIn, Pandora, etc.)

Screenshot of queue attached: img_1434

jishi commented 7 years ago

@jplourde5 I guess the getQueue call fails if you aren't playing from the queue, but why would it need the queue in the first place? Are you trying to merge results or something?

jplourde5 commented 7 years ago

Radio is a separate command from song and should not be doing anything with the queue. But he appears to be issuing the song command, not the radio command.

I will have to play with it when I get a chance, hopefully next week. I'm out of pocket at the moment. I'll look at the Pandora Thumbs problem too.

jplourde5 commented 7 years ago

I clear my queue and issued /living room/musicsearch/apple/song/closer and Closer, The Chainsmokers played.

I then cleared my queue, played an Apple Radio station using the Sonos controller, then issued /living room/musicsearch/apple/song/closer and the same song played.

Tried the same using Pandora, and everything worked also.

I don't seem to be seeing the same problem. I'm using the latest release.

jishi commented 7 years ago

I think I'm reading the stack trace wrong. I guess it fails when trying to start the apple radio station, meaning, setting the radio station URI in the setAVTransport call

jplourde5 commented 7 years ago

I can't reproduce the problem.

crbender, Can you give me the exact steps to reproduce the problem using the latest release?

ghost commented 7 years ago

I'm having this same issue. /living room/musicsearch/spotify/song/red+hot+chili+peppers is the url I'm calling. As for my queue, it is empty. This was working the other day; however, I had items in my queue. I'll try manually adding an item to the queue using the Sonos app and retry this.

ghost commented 7 years ago

I put the following console.log into the sonos-discovery/lib/helpers/soap.js file

console.log('sonos-discovery soap', url, action, body.length, body);

This is the output

sonos-discovery soap http://192.168.1.4:1400/MediaRenderer/AVTransport/Control urn:schemas-upnp-org:service:AVTransport:1#Next 250 <Buffer 3c 73 3a 45 6e 76 65 6c 6f 70 65 20 78 6d 6c 6e 73 3a 73 3d 22 68 74 74 70 3a 2f 2f 73 63 68 65 6d 61 73 2e 78 6d 6c 73 6f 61 70 2e 6f 72 67 2f 73 6f ... >

A console.log of the response did not get triggered, which leads me to believe the promise isn't being returned, which makes me wonder if something changed in the Sonos API.

As for adding to the queue, it does do that.

/living%20room/queue shows the song was added.

crbender commented 7 years ago

@jplourde5 -- To recreate error: From an empty queue and nothing playing on the speakers:

  1. Start playing a station through the Sonos app or by: /living room/musicsearch/apple/station/charting now
  2. Try to search and play a song: /living room/musicsearch/apple/song/closer

Error: {"status":"error","error":"Got status 500 when invoking /MediaRenderer/AVTransport/Control","stack":"Error\n at Object.invoke (/home/user/node-sonos-http-api/node_modules/sonos-discovery/lib/helpers/soap.js:95:10)\n at Player.setAVTransport (/home/user/node-sonos-http-api/node_modules/sonos-discovery/lib/models/Player.js:651:15)\n at player.coordinator.getQueue.then.then.then (/home/user/node-sonos-http-api/lib/actions/musicSearch.js:265:47)\n at process._tickDomainCallback (internal/process/next_tick.js:129:7)"}

Note: the song is added to the queue, but does not play.

ghost commented 7 years ago

I have the exact opposite results as @crbender. I ran the /living room/musicsearch/apple/station/charting now url, which returned success, then the /living room/musicsearch/apple/song/closer url, which also returned success.

I also tried the following to success /living room/clearqueue /living room/musicsearch/apple/station/charting now /living room/musicsearch/apple/song/closer

It seems to no longer be returning an error, no matter the combination of things I do.

BTW, the error did persist through restarts of the node server, as well as the raspberry pi it is running on. Running /living room/musicsearch/apple/station/charting now somehow resolved this issue for me.

crbender commented 7 years ago

You've got a typo in your second call @RobertSheaO : /living room/musicsearch/apple/**song**/station/charting now -- you're playing a song which plays from the queue and doesn't throw the error.

Remove song and try it again: /living room/musicsearch/apple/station/charting now

elmedico27 commented 7 years ago

I was getting a similar error when performing a search for a local track, however it only occurred right after I first loaded my library and when the player was "empty" (app is showing "No music"). When that was the case, running /master bedroom/musicsearch/library/song/rylynn added the song to the queue, did not play it, then kicked out this error:

{"status":"error","error":"Got status 500 when invoking /MediaRenderer/AVTransport/Control","stack":"Error\n at Object.invoke (/home/pi/node_scripts/node-sonos-http-api/node_modules/sonos-discovery/lib/helpers/soap.js:95:10)\n at Player.nextTrack (/home/pi/node_scripts/node-sonos-http-api/node_modules/sonos-discovery/lib/models/Player.js:406:15)\n at player.coordinator.getQueue.then.then.then.then (/home/pi/node_scripts/node-sonos-http-api/lib/actions/musicSearch.js:270:47)\n at process._tickDomainCallback (internal/process/next_tick.js:129:7)"}

I manually played a song via the app then tried again and it worked, both while the song was playing and after I'd paused the song. I cleared out the queue to "empty" the player and it worked again. Played a station from Amazon and tried it, worked again -- I can no longer reproduce the error. @crbender is this the first time you've played something from this service?

ghost commented 7 years ago

@crbender That was a copy/paste typo on my part, I did in fact call /living room/musicsearch/apple/station/charting now, which resolved the issue. I just ran through it again to verify. I've since updated my post above.