htilly / zenmusic

Slack / Sonos / Spotify / Node.js - Control Sonos through #Slack
125 stars 36 forks source link

HTTP 405 Issue? #5

Closed matthewknee closed 8 years ago

matthewknee commented 8 years ago

Hey there!

Followed all the instructions. Setup a heroku server and port forward to our Sonos.

Slack bot working A OK, but I have issues connecting to Sonos...see error below...any ideas?

2016-07-29T06:37:45.915581+00:00 app[web.1]: Error: HTTP response code 405 for "urn:schemas-upnp-org:service:RenderingControl:1#GetVolume" 2016-07-29T06:37:45.915601+00:00 app[web.1]: at Request._callback (/app/node_modules/sonos/lib/sonos.js:97:23) 2016-07-29T06:37:45.915602+00:00 app[web.1]: at Request.self.callback (/app/node_modules/sonos/node_modules/request/request.js:198:22) 2016-07-29T06:37:45.915603+00:00 app[web.1]: at emitTwo (events.js:106:13) 2016-07-29T06:37:45.915604+00:00 app[web.1]: at Request.emit (events.js:191:7) 2016-07-29T06:37:45.915604+00:00 app[web.1]: at Request. (/app/node_modules/sonos/node_modules/request/request.js:1035:10) 2016-07-29T06:37:45.915605+00:00 app[web.1]: at emitOne (events.js:101:20) 2016-07-29T06:37:45.915606+00:00 app[web.1]: at Request.emit (events.js:188:7) 2016-07-29T06:37:45.915609+00:00 app[web.1]: at IncomingMessage. (/app/node_modules/sonos/node_modules/request/request.js:962:12) 2016-07-29T06:37:45.915610+00:00 app[web.1]: at emitNone (events.js:91:20) 2016-07-29T06:37:45.915611+00:00 app[web.1]: at IncomingMessage.emit (events.js:185:7) 2016-07-29T06:37:45.915612+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12) 2016-07-29T06:37:45.915612+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:74:11) 2016-07-29T06:37:45.915613+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:98:9) undefined 2016-07-29T06:38:02.822289+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 2016-07-29T06:38:02.822380+00:00 heroku[web.1]: Stopping process with SIGKILL 2016-07-29T06:38:02.949865+00:00 heroku[web.1]: State changed from starting to crashed 2016-07-29T06:38:02.933699+00:00 heroku[web.1]: Process exited with status 137

htilly commented 8 years ago

Hi!

What happen if you browse to: http://sonos_ip:1400/status from the heroku? Where sonos_ip is the same as in you config file?

BR Tilly

htilly commented 8 years ago

How does your Sonos setup look like? Are you pointing to a hub or player?

Found this in another forum:

I think this might be the problem, because it's a bridge it doesn't have all the audio services as it just provides a WiFi for your other sonos devices. Try using the IP address of a ZonePlayer (one that plays music) and see if that yields something more positive ;)

matthewknee commented 8 years ago

It's a player, just the one PLAY:3 speaker - pretty simple setup.

    _____________________________

From: Henrik Tilly notifications@github.com Sent: Friday, July 29, 2016 6:14 PM Subject: Re: [htilly/zenmusic] HTTP 405 Issue? (#5) To: htilly/zenmusic zenmusic@noreply.github.com Cc: Author author@noreply.github.com, matthewknee mattknee@donesafe.com

How does your Sonos setup look like? Are you pointing to a hub or player?

Found this in another forum:

I think this might be the problem, because it's a bridge it doesn't have all the audio services as it just provides a WiFi for your other sonos devices. Try using the IP address of a ZonePlayer (one that plays music) and see if that yields something more positive ;)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

matthewknee commented 8 years ago

It works, I get a list of links

On Fri, Jul 29, 2016 at 6:04 PM +1000, "Henrik Tilly" notifications@github.com wrote:

Hi!

What happen if you browse to:

http://:1400/status from the heroku?

Where sonos_ip is the same as in you config file?

BR

Tilly

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

htilly commented 8 years ago

Seems to be a heroku issue. See: http://stackoverflow.com/questions/15693192/heroku-node-js-error-web-process-failed-to-bind-to-port-within-60-seconds-of

Im on the road right now. Will have a closer look when I get back.

Have you tried it on a local computer?

/Tilly

htilly commented 8 years ago

Also found this: https://github.com/slackhq/node-slack-sdk/issues/39

htilly commented 8 years ago

.. and when U get it to run, please see https://github.com/htilly/zenmusic/issues/4

You will need to edit node_modules/sonos/lib/sonos.js and add two functions.

htilly commented 8 years ago

So after creating my first account in Heroku I think I managed to get it running..
BE AWARE, it´s an UGLY hack.. but it seems to work :) Look in index.js and uncomment the Heoku part.

U will still need to edit the node_modules/sonos/lib/sonos.js file... see above.

BR Tilly

matthewknee commented 8 years ago

Thanks Tilly! Really appreciate your help with this! I sorted the index.js file. Forgive me Im a bit of newbie...Since that node-sonos module is not in my github repo im not sure how to edit it? How exactly do I go about editing it or perhaps I should reinstall the whole module?

htilly commented 8 years ago

Try installing again. Fixed the package.json. Should pull the latest commit including getQueue and addSpotifyQueue so you don´t need to edit the file.

BR Tilly

matthewknee commented 8 years ago

Thanks Tilly - appreciate your help mate. I reinstalled everything from scratch - still getting that damn 405 error. See logs from fresh install below. Any ideas?

2016-08-05T11:52:16.560880+00:00 heroku[api]: Deploy de23a4b by mattknee@donesafe.com 2016-08-05T11:52:17.095582+00:00 heroku[web.1]: Restarting 2016-08-05T11:52:17.096129+00:00 heroku[web.1]: State changed from up to starting 2016-08-05T11:52:18.605505+00:00 heroku[web.1]: Starting process with command node index.js 2016-08-05T11:52:21.201257+00:00 heroku[web.1]: Process exited with status 143 2016-08-05T11:52:21.524767+00:00 app[web.1]: You have undefined unread undefined 2016-08-05T11:52:49.329491+00:00 app[web.1]: Received: message #music @mk 1470397969.000012 "status" 2016-08-05T11:52:49.329717+00:00 app[web.1]: term status 2016-08-05T11:52:49.823607+00:00 app[web.1]: Error: HTTP response code 405 for "urn:schemas-upnp-org:service:AVTransport:1#GetTransportInfo" 2016-08-05T11:52:49.823625+00:00 app[web.1]: at Request._callback (/app/node_modules/sonos/lib/sonos.js:138:23) 2016-08-05T11:52:49.823626+00:00 app[web.1]: at Request.self.callback (/app/node_modules/sonos/node_modules/request/request.js:198:22) 2016-08-05T11:52:49.823627+00:00 app[web.1]: at emitTwo (events.js:106:13) 2016-08-05T11:52:49.823627+00:00 app[web.1]: at Request.emit (events.js:191:7) 2016-08-05T11:52:49.823628+00:00 app[web.1]: at Request. (/app/node_modules/sonos/node_modules/request/request.js:1035:10) 2016-08-05T11:52:49.823628+00:00 app[web.1]: at emitOne (events.js:101:20) 2016-08-05T11:52:49.823629+00:00 app[web.1]: at Request.emit (events.js:188:7) 2016-08-05T11:52:49.823630+00:00 app[web.1]: at IncomingMessage. (/app/node_modules/sonos/node_modules/request/request.js:962:12) 2016-08-05T11:52:49.823631+00:00 app[web.1]: at emitNone (events.js:91:20) 2016-08-05T11:52:49.823631+00:00 app[web.1]: at IncomingMessage.emit (events.js:185:7) 2016-08-05T11:52:49.823632+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12) 2016-08-05T11:52:49.823633+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:74:11) 2016-08-05T11:52:49.823633+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:98:9)

htilly commented 8 years ago

Also, in you configfile, the IP adress should be: "sonos" : "1.2.3.4",

Do not enter the port number, i.e. "1.2.3.4:1400". This will not work!

BR Tilly

matthewknee commented 8 years ago

thats it! thanks for your all your help Tilly, we have a very happy office now!

matthewknee commented 8 years ago

ahh so close.

So most functions are working without a hitch, except the play function. Keep getting an "Unhandled rejection SlackRTMError: no channel id" error...see below

2016-08-07T01:11:03.916283+00:00 app[web.1]: Received: message #music-admin @mk 1470532263.000020 "search hotel california" 2016-08-07T01:11:03.917050+00:00 app[web.1]: term search 2016-08-07T01:11:04.443776+00:00 app[web.1]: { href: 'https://api.spotify.com/v1/search?query=hotel+california&offset=0&limit=3&type=track&market=US', 2016-08-07T01:11:04.443763+00:00 app[web.1]: { tracks: 2016-08-07T01:11:04.443780+00:00 app[web.1]: previous: null, 2016-08-07T01:11:04.443779+00:00 app[web.1]: offset: 0, 2016-08-07T01:11:04.443777+00:00 app[web.1]: items: [ [Object], [Object], [Object] ], 2016-08-07T01:11:04.443780+00:00 app[web.1]: total: 2142 } } 2016-08-07T01:11:04.443778+00:00 app[web.1]: next: 'https://api.spotify.com/v1/search?query=hotel+california&offset=3&limit=3&type=track&market=US', 2016-08-07T01:11:19.037885+00:00 app[web.1]: Received: message #music-admin @mk 1470532278.000024 "play Eagles - Hotel California" 2016-08-07T01:11:19.037931+00:00 app[web.1]: term play 2016-08-07T01:11:20.478748+00:00 app[web.1]: [ null, true ] 2016-08-07T01:11:20.508617+00:00 app[web.1]: Unhandled rejection SlackRTMError: no channel id 2016-08-07T01:11:20.508621+00:00 app[web.1]: at RTMClient._handleWsMessageViaEventHandler (/app/node_modules/@slack/client/lib/clients/rtm/client.js:460:12) 2016-08-07T01:11:20.508622+00:00 app[web.1]: at RTMClient.handleWsMessage (/app/node_modules/@slack/client/lib/clients/rtm/client.js:420:10) 2016-08-07T01:11:20.508623+00:00 app[web.1]: at WebSocket.wrapper (/app/node_modules/lodash/lodash.js:4597:19) 2016-08-07T01:11:20.508627+00:00 app[web.1]: at emitTwo (events.js:106:13) 2016-08-07T01:11:20.508628+00:00 app[web.1]: at WebSocket.emit (events.js:191:7) 2016-08-07T01:11:20.508629+00:00 app[web.1]: at /app/node_modules/ws/lib/Receiver.js:536:18 2016-08-07T01:11:20.508630+00:00 app[web.1]: at /app/node_modules/ws/lib/Receiver.js:368:7 2016-08-07T01:11:20.508630+00:00 app[web.1]: at /app/node_modules/ws/lib/PerMessageDeflate.js:249:5 2016-08-07T01:11:20.508631+00:00 app[web.1]: at afterWrite (_stream_writable.js:361:3) 2016-08-07T01:11:20.508631+00:00 app[web.1]: at onwrite (_stream_writable.js:352:7) 2016-08-07T01:11:20.508632+00:00 app[web.1]: at WritableState.onwrite (_stream_writable.js:89:5) 2016-08-07T01:11:20.508632+00:00 app[web.1]: at afterTransform (_stream_transform.js:79:3) 2016-08-07T01:11:20.508633+00:00 app[web.1]: at TransformState.afterTransform (_stream_transform.js:54:12)

matthewknee commented 8 years ago

Also getting an internal error for add function.

2016-08-07T01:17:22.957796+00:00 app[web.1]: Received: message #music-admin @mk 1470532642.000027 "add Eagles - Hotel California" 2016-08-07T01:17:22.957855+00:00 app[web.1]: term add 2016-08-07T01:17:23.328543+00:00 app[web.1]: { tracks: 2016-08-07T01:17:23.328556+00:00 app[web.1]: { href: 'https://api.spotify.com/v1/search?query=Eagles+-+Hotel+California&offset=0&limit=1&type=track&market=US', 2016-08-07T01:17:23.328557+00:00 app[web.1]: items: [ [Object] ], 2016-08-07T01:17:23.328557+00:00 app[web.1]: limit: 1, 2016-08-07T01:17:23.328558+00:00 app[web.1]: next: 'https://api.spotify.com/v1/search?query=Eagles+-+Hotel+California&offset=1&limit=1&type=track&market=US', 2016-08-07T01:17:23.328559+00:00 app[web.1]: offset: 0, 2016-08-07T01:17:24.354487+00:00 app[web.1]: Error: HTTP response code 500 for "urn:schemas-upnp-org:service:AVTransport:1#AddURIToQueue" 2016-08-07T01:17:24.354499+00:00 app[web.1]: at Request._callback (/app/node_modules/sonos/lib/sonos.js:138:23) 2016-08-07T01:17:24.354499+00:00 app[web.1]: at Request.self.callback (/app/node_modules/sonos/node_modules/request/request.js:198:22) 2016-08-07T01:17:24.354501+00:00 app[web.1]: at emitTwo (events.js:106:13) 2016-08-07T01:17:24.354501+00:00 app[web.1]: at Request.emit (events.js:191:7) 2016-08-07T01:17:24.354502+00:00 app[web.1]: at Request. (/app/node_modules/sonos/node_modules/request/request.js:1035:10) 2016-08-07T01:17:24.354503+00:00 app[web.1]: at emitOne (events.js:101:20) 2016-08-07T01:17:24.354503+00:00 app[web.1]: at Request.emit (events.js:188:7) 2016-08-07T01:17:24.354504+00:00 app[web.1]: at IncomingMessage. (/app/node_modules/sonos/node_modules/request/request.js:962:12) 2016-08-07T01:17:24.354505+00:00 app[web.1]: at emitNone (events.js:91:20) 2016-08-07T01:17:24.354506+00:00 app[web.1]: at IncomingMessage.emit (events.js:185:7) 2016-08-07T01:17:24.354506+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12) 2016-08-07T01:17:24.354507+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:74:11) 2016-08-07T01:17:24.354508+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:98:9)

htilly commented 8 years ago

Small steps forward :)

1: Is the bot invited to both channels specified in the config file?

2: Also, what version of node are U running?

matthewknee commented 8 years ago

Yes very small... :+1:

  1. Yes
  2. Latest current version
htilly commented 8 years ago

Hmm.. "play" is not intended to be used in that way. It´s an admin command if you have paused or stoped it earlier. Only works in the admin channel. Play takes no arguments..

Does "status" work?

That will indicate that you have a working network connection to the Sonos system. Should reply with something like "Sonos is currently sleeping!" or similar =) Works in both admin and non-admin channel.

Unless status works nor will add, append etc.

BR Tilly

matthewknee commented 8 years ago

whoops, but yes status works. I tested and every function works except play and append !

I used the same example from your readme below. I did search volbeat that worked. add add Volbeat - Still Counting error!

In the logs im getting "Error: HTTP response code 500 for "urn:schemas-upnp-org:service:AVTransport:1#AddURIToQueue"

2016-08-08T06:05:22.442981+00:00 app[web.1]: Received: message #music-admin @mk 1470636322.000055 "search volbeat" 2016-08-08T06:05:22.443096+00:00 app[web.1]: term search 2016-08-08T06:05:22.782461+00:00 app[web.1]: { tracks: 2016-08-08T06:05:22.782477+00:00 app[web.1]: { href: 'https://api.spotify.com/v1/search?query=volbeat&offset=0&limit=3&type=track&market=AU', 2016-08-08T06:05:32.751444+00:00 app[web.1]: Received: message #music-admin @mk 1470636332.000059 "add Volbeat - Still Counting" 2016-08-08T06:05:32.751564+00:00 app[web.1]: term add 2016-08-08T06:05:33.248171+00:00 app[web.1]: { tracks: 2016-08-08T06:05:33.248182+00:00 app[web.1]: { href: 'https://api.spotify.com/v1/search?query=Volbeat+-+Still+Counting&offset=0&limit=1&type=track&market=AU', 2016-08-08T06:05:34.260487+00:00 app[web.1]: [ null, [ { '$': [Object] } ] ] 2016-08-08T06:05:34.940810+00:00 app[web.1]: Error: HTTP response code 500 for "urn:schemas-upnp-org:service:AVTransport:1#AddURIToQueue" 2016-08-08T06:05:34.940822+00:00 app[web.1]: at Request._callback (/app/node_modules/sonos/lib/sonos.js:138:23) 2016-08-08T06:05:34.940823+00:00 app[web.1]: at Request.self.callback (/app/node_modules/sonos/node_modules/request/request.js:198:22) 2016-08-08T06:05:34.940824+00:00 app[web.1]: at Request.emit (events.js:191:7) 2016-08-08T06:05:34.940825+00:00 app[web.1]: at Request. (/app/node_modules/sonos/node_modules/request/request.js:1035:10) 2016-08-08T06:05:34.940825+00:00 app[web.1]: at emitOne (events.js:101:20) 2016-08-08T06:05:34.940826+00:00 app[web.1]: at Request.emit (events.js:188:7) 2016-08-08T06:05:34.940827+00:00 app[web.1]: at IncomingMessage. (/app/node_modules/sonos/node_modules/request/request.js:962:12) 2016-08-08T06:05:34.940827+00:00 app[web.1]: at emitNone (events.js:91:20) 2016-08-08T06:05:34.940828+00:00 app[web.1]: at IncomingMessage.emit (events.js:185:7) 2016-08-08T06:05:34.940829+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12) 2016-08-08T06:05:34.940824+00:00 app[web.1]: at Request.emit (events.js:191:7) 2016-08-08T06:05:34.940826+00:00 app[web.1]: at Request.emit (events.js:188:7) 2016-08-08T06:05:34.940827+00:00 app[web.1]: at emitNone (events.js:91:20) 2016-08-08T06:05:34.940829+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12) 2016-08-08T06:05:34.940830+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:98:9) 2016-08-08T06:05:34.940824+00:00 app[web.1]: at Request.emit (events.js:191:7) 2016-08-08T06:05:34.940824+00:00 app[web.1]: at emitTwo (events.js:106:13) 2016-08-08T06:05:34.940826+00:00 app[web.1]: at Request.emit (events.js:188:7) 2016-08-08T06:05:34.940827+00:00 app[web.1]: at IncomingMessage. (/app/node_modules/sonos/node_modules/request/request.js:962:12) 2016-08-08T06:05:34.940829+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12)

htilly commented 8 years ago

Ok. Then we know the problem. For some reason the latest version of node-sonos isn´t pulled. I added two function to node-sonos which is used by both "play" and "add".

This is the one you need: https://github.com/bencevans/node-sonos/blob/master/lib/sonos.js (funktions: getQueue and addSpotifyQueue)

In order to get the latest from git you will type the following on a regular computer: npm install https://github.com/bencevans/node-sonos.git#bfb995610c8aa20bda09e370b0f5d31ba0caa6a0 --save

Now, this is a little hard in Heroku, but it should work anyway because in the package.json I have specified: "sonos": "git+https://github.com/bencevans/node-sonos.git#bfb995610c8aa20bda09e370b0f5d31ba0caa6a0"

Your Sonos is updated with the latest version and you do have Spotify configured on it.. right !? ;)

htilly commented 8 years ago

Well.. I just installed "vim" in Heroku and it does pull the right version of node-sonos after a fresh install. Im getting to know Heroku along the way =)

So, need to dig deeper in this.

You where running a PLAY:3, right? No other units, bridges or anything else? It seems to have problem working with the queue.

/tilly

matthewknee commented 8 years ago

thanks again tilly! Ill reinstall node-sonos now and see if that makes a difference. Yes we have latest Sonos software installed and Spotify all setup...that part is working (i.e. search works fine) Glad you are getting to know Heroku - its a pretty good service...

Yes we have just the single PLAY:3, nothing else connected....I can list the queue, flush it etc. just not add

matthewknee commented 8 years ago

still getting the same error :(

JeromeBouvard commented 8 years ago

same here ! everything working except the ADD

matthewknee commented 8 years ago

any ideas tilly?

htilly commented 8 years ago

Hi.. yea.. I do have an idea, but I don´t know why =) Try a new "git pull". index.js has been updated with new functions.

The interesting thing is that when I run this version I get the 500 error. :-( but other report that it works!

Please try it and come back with feedback!

BR Tilly

matthewknee commented 8 years ago

alrighty! appears to be working...Will check on Monday in the office its playing...

htilly commented 8 years ago

Nice!

htilly commented 8 years ago

Dif it work?

matthewknee commented 8 years ago

Yes it did!! Having lots of fun in the office, thanks for all your help Tilly!

matthewknee commented 8 years ago

We have a Zapier setup that fires off a theme song for meetings... You know a 'play now' function would be awesome...add a new song to queue and set to play right away...

htilly commented 8 years ago

I'll put it in the ToDo =)

/Tilly