sarkonovich / Alexa-Hue

Control Hue Lights with Alexa
131 stars 28 forks source link

Receiving 404 response from Sinatra #7

Closed staytonm closed 8 years ago

staytonm commented 8 years ago

I followed the instructions and am getting some errors. The Ruby window (I'm using the Ruby for windows installer) is showing the requests coming in, but it seems to be returning 404 responses. Then on the AWS lambda side, I'm seeing SyntaxError: Unexpected token <. Which I assume is due to the 404 being returned instead of the correct response. I've skipped the ngrok for now to eliminate variables and simply exposed the port for the Sinatra in Ruby to be public using port forwarding on my router. I also have a static public IP, so no dynamic IP issues to worry about. I have tested and can access sinatra from outside of my network (tested using a VPN from another machine). When I navigate directly to the site using the url and the port (either inside or outside the network), I'm getting the sinatra 404 page as well. Which I originally assumed was because I wasn't posting with the JSON object, but I'm not sure if that's an issue as well. Any help would be greatly appreciated. I'm happy to provide any additional information needed.

Error from Sinatra: c:\Ruby22\AlexaHue>ruby app.rb [2016-03-27 12:52:55] INFO WEBrick 1.3.1 [2016-03-27 12:52:55] INFO ruby 2.2.4 (2015-12-16) [i386-mingw32] == Sinatra (v1.4.7) has taken the stage on 4567 for development with backup from WEBrick [2016-03-27 12:52:55] INFO WEBrick::HTTPServer#start: pid=10992 port=4567 ec2-52-205-255-162.compute-1.amazonaws.com - - [27/Mar/2016:12:53:11 Eastern Day light Time] "POST / HTTP/1.1" 404 515

Error from AWS Lambda:

START RequestId: 9a58fa47-f433-11e5-93a7-7bd2784fb5e8 Version: $LATEST 2016-03-27T15:50:18.014Z 9a58fa47-f433-11e5-93a7-7bd2784fb5e8 SyntaxError: Unexpected token < at Object.parse (native) at IncomingMessage. (/var/task/index.js:40:38) at IncomingMessage.emit (events.js:117:20) at _stream_readable.js:944:16 at process._tickCallback (node.js:448:13) END RequestId: 9a58fa47-f433-11e5-93a7-7bd2784fb5e8 REPORT RequestId: 9a58fa47-f433-11e5-93a7-7bd2784fb5e8 Duration: 456.97 ms Billed Duration: 500 ms Memory Size: 128 MB Max Memory Used: 9 MB
Process exited before completing request

sarkonovich commented 8 years ago

I'm guessing that the lambda function is set up wrong.

Did you copy and paste the lambda_passthrough.js into the code window? Also, under "Event Sources", did you set the event source to "Alexa Skills Kit"?

staytonm commented 8 years ago

Yes, I have the lambda_passthrough.js code pasted into the code section and I have also replaced the appId and url in the handlers object. The only event source that is listed is the "Alexa Skills Kit". When diving into the settings of the skill, I haven't completely published it, it's just sitting in test mode, but my Echo seems to recognize it fine. I can also go to the service simulator in the skill and initiate a command and see it pop up in the Sinatra window, however, I get the 404.

staytonm commented 8 years ago

Also, to clarify, I'm able to give a verbal command to the Echo, and I'm seeing the 404 pop up on the Sinatra window. So I'm thinking that means the communication path from Echo to the lambda to the skill and back to my home computer is working fine.

sarkonovich commented 8 years ago

Hmm. You certainly don't want to publish it, so that's fine!

And, looking more closely, it doesn't seem to be Lambda. You should be getting at 200 code from sinatra. It seems like the skills isn't going to the right route, or something. It should look like:

"POST /lights HTTP/1.1" 200 216

But you are just showing

for the route.

Does Alexa say anything, e.g., 'There was a problem with the requested skills response?"

On Sun, Mar 27, 2016 at 10:14 AM, staytonm notifications@github.com wrote:

Yes, I have the lambda_passthrough.js code pasted into the code section and I have also replaced the appId and url in the handlers object. The only event source that is listed is the "Alexa Skills Kit". When diving into the settings of the skill, I haven't completely published it, it's just sitting in test mode, but my Echo seems to recognize it fine. I can also go to the service simulator in the skill and initiate a command and see it pop up in the Sinatra window, however, I get the 404.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/sarkonovich/Alexa-Hue/issues/7#issuecomment-202107565

staytonm commented 8 years ago

That's exactly what Alexa says. "There was a problem with the requested skills response"

sarkonovich commented 8 years ago

I think I know. I bet you left off the "/lights" when pasting the route into lambda.

Steve

On Sun, Mar 27, 2016 at 10:24 AM, staytonm notifications@github.com wrote:

Also, to clarify, I'm able to give a verbal command to the Echo, and I'm seeing the 404 pop up on the Sinatra window. So I'm thinking that means the communication path from Echo to the lambda to the skill and back to my home computer is working fine.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/sarkonovich/Alexa-Hue/issues/7#issuecomment-202109699

staytonm commented 8 years ago

Doh! That did it. I spent so much time trying to get ngrok working, that I was trying all sorts of different URLs to get that to work. I think when I eventually disabled it and enabled port forwarding, I just put in the IP and port. Forgot the specific path. Thanks so much!