bklavet / Echo-skill-to-control-Directv

amazon echo skill that will control a networked Directv Receiver so that users can control Directv with their voice
18 stars 67 forks source link

Remote Endpoint Could not be Called #2

Closed ChipHappens closed 8 years ago

ChipHappens commented 8 years ago

When testing the new skill, I'm getting an error: "The remote endpoint could not be called, or the response it returned was invalid."

I included my lambda request below. Any ideas?

{ "session": { "sessionId": "SessionId.cd480c53-fe21-4ea1-9fd9-_", "application": { "applicationId": "amzn1.echo-sdk-ams.app._" }, "user": { "userId": "amzn1.ask.account.****_" }, "new": true }, "request": { "type": "IntentRequest", "requestId": "EdwRequestId.2c7e46d0-123f-46dc-a0b2-_**", "timestamp": "2016-05-19T05:07:24Z", "intent": { "name": "DirectvIntent", "slots": { "Control": { "name": "Control", "value": "Guide" } } }, "locale": "en-US" }, "version": "1.0"

vmweaver commented 8 years ago

Does your dtv box respond to Web calls on the address you have on the index file?

I will see if I can reproduce this error. Seems to be thrown by lots of different reasons.

-- Mark On May 19, 2016 12:14 AM, "ChipHappens" notifications@github.com wrote:

When testing the new skill, I'm getting an error: "The remote endpoint could not be called, or the response it returned was invalid."

I included my lambda request below. Any ideas?

{ "session": { "sessionId": "SessionId.cd480c53-fe21-4ea1-9fd9-3ca6c848f545", "application": { "applicationId": "amzn1.echo-sdk-ams.app.acbe3729-09a3-497c-95fe-4d8ee263c131" }, "user": { "userId": "amzn1.ask.account.AFP3ZWPOS2BGJR7OWJZ3DHPKMOMNWY4AY66FUR7ILBWANIHQN73QG7MJKVQUZM7VJMJZ4CMVWIWHQGGJNIHZ7EBLJVUZAYQYZU4EGXG2G77WI46MKHV4FWM2VNUPTXWWKMS3TLYZWDZODY2C54LUG6MYMPLRKC555H47C5KVKDYZ7ECMG5U34HHRDS75UFU3GKFFTZAIXHWQGMQ" }, "new": true }, "request": { "type": "IntentRequest", "requestId": "EdwRequestId.2c7e46d0-123f-46dc-a0b2-95ef7a5eeffb", "timestamp": "2016-05-19T05:07:24Z", "intent": { "name": "DirectvIntent", "slots": { "Control": { "name": "Control", "value": "Guide" } } }, "locale": "en-US" }, "version": "1.0"

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/bklavet/Echo-skill-to-control-Directv/issues/2

vmweaver commented 8 years ago

I was able to reproduce this one case where the AWS Alexa "application" was pointing to a Lambda URN that was not configured for that AWS Application ID.

Do you have multiple Lambda Functions? Since a Lambda function (URN) is tied to a specific AWS Alexa ApplicationId, you will get this error if there is a mismatch.

In other words: Is the APP ID you are using in the Index file (in the Lambda Function you are pointing to): "amzn1.echo-sdk-ams.app.acbe3729-09a3-497c-95fe-4d8ee263c131"?

ChipHappens commented 8 years ago

Thanks @mawrew19 for the quick reply!

In the index file, am I suppose to assign my local IP to the local_ip variable (i.e., replace the 'xxx.xxx.xxx.xxx' with 192.168.1.xxx)? I think this is where I am running into problems. I did set up port forwarding as mentioned in the index file.

As far as the multiple lambda functions, this is my first one. I have attempted to recreate this one a couple times but have deleted past attempts. I have confirmed that the above AppID is correct from the Amazon developer site.

Another thing to mention, the end goal is to have this work on a c41 genie client. Do you know if it accepts the same commands as the HR44?

Thanks again for you help!

bklavet commented 8 years ago

Hello Chip, you don't want your local IP you want your wan IP. Open a browser on your network and google "what's my IP" and it will show you what you need to put in.

To control the client you will have to add the MAC address of the client to the Index file... Since the Genie and Clients all work off the same IP. For users that have multiple receivers and/or clients, it may be easier to make multiples of this skill with different envoke names for each receiver.

So a sample command that would have the mac address included would look like this I believe: to turn on client: www.(IP Addreess):8080/remote/processKey?key=poweron&hold=keyPress&clientAddr=(MAC Address of client)

If you replace with your local lan 192.168.... and paste the above in your browser of a computer on the same network as the directv... This should turn the client ON locally.

ChipHappens commented 8 years ago

@bklavet Thank you so much. I'll have to try this when I get home today.

ChipHappens commented 8 years ago

@bklavet I'm trying to test the concept above of putting the above snippet in a chrome browser, and it isn't working. I opened port 8080 to aim at my individual genie client (it has it's own internal IP address). The Main box (HR-44) has an IP, the genie bridge has an IP, and all three genie clients have their own IP.

Code in browser: www.108.23.23.104:8080/remote/processKey?key=pause&hold=keyPress&clientAddr=28:32:c5:e4:b3:ae

vmweaver commented 8 years ago

@ChipHappens you shouldn't have www. in front.

http://108.23.23.104:8080/remote/processKey?key=pause&hold=keyPress&clientAddr=28:32:c5:e4:b3:ae

Please be careful. There is no security on these devices. I don't know much about the genie clients as I only have my main box which I use. So you have your external ip address forwarding traffic to your genie client's internal address on port 8080? Are there any firewall rules that may block that inbound traffic? I don't see these ports open on that address.

ChipHappens commented 8 years ago

@mawrew19 I changed the IP before posting for that reason. I'll have to try without the www

ChipHappens commented 8 years ago

@mawrew19 will the call to the external Wan IP work if I'm on the network?

vmweaver commented 8 years ago

yes it should work if configured properly. You could test the url by using the internal IP address instead. This would at least validate the syntax was correct. I know on my dtv setup I had to enable a feature to be able to control it via the network.

bklavet commented 8 years ago

Sorry about the www slip. Were you able to get the client to pause?

ChipHappens commented 8 years ago

I got it working on my main receiver (HR44)using the browser, just cant get the genie mini to work using the '&clientAddr=28:32:c5:e4:b3:ae' part

ChipHappens commented 8 years ago

The following code shows in the browser window: {"status": { "code": 400, "commandResult": 1, "msg": "Bad Request.Exception=null", "query": "/remote/processKey?key=guide&hold=keyPress&clientAddr=28:32:c5:e4:b3:ae" }}

vmweaver commented 8 years ago

The api specification, I think, says the MAC address should be in all caps with no colons. Give that a try.

ChipHappens commented 8 years ago

@mawrew19 You are the man! worked like a charm!

vmweaver commented 8 years ago

Awesomeness.... Making good progress here!!!! Good stuff.

ChipHappens commented 8 years ago

Sorry one more question for the night and then I have to go to bed. I can't get it to work in the browser using my external IP. Any ideas? Port scanner shows that it is open. I logged in to my whole home settings and set external devices to allow.

ChipHappens commented 8 years ago

@mawrew19 It is saying in the browser: "The site can't be reached. (external IP) refused to connect."

vmweaver commented 8 years ago

How do you have your router setup to forward traffic? What kind of router do you have? Are you doing port forwarding? Port scanner shows 8080 is listening on your external address?

vmweaver commented 8 years ago

Are you forwarding to your genie client ip or the ip of your main receiver/server?

ChipHappens commented 8 years ago

Using a 2Wire router for ATT Uverse, set up for both tcp and udp port 8080 to forward to my main HR44 box (used the internal IP for this box when it worked internally).

vmweaver commented 8 years ago

Not sure what model you have, but this may help.

https://www.att.com/esupport/article.html#!/u-verse-high-speed-internet/KM1010280

May need a fw rule or something.

ChipHappens commented 8 years ago

@mawrew19 I checked on the documentation, and verified I followed those steps to setup port forwarding. I'm going to try to put the directv box in the dmz. will report back shortly.

vmweaver commented 8 years ago

When you set it up, does the firewall setting make you choose a "from" port as well as a "to" port"? If so, the from port should be any, I think, and to port should be 8080. Grasping a bit here...sorry.

bklavet commented 8 years ago

Should work for sure in the dmz. If not try the command from a different internet connection, like a smart phone network.

ChipHappens commented 8 years ago

@mawrew19 It has to be the port forwarding that I'm not getting right. I have successfully set up port forwarding for my Plex server in the past. The "from" and "to" port are to set a range of ports to be forwarded to the specified device. I tried from my phone, didn't work using the external IP. Putting the box in the DMZ timed out when i sent the request after about 15 seconds

vmweaver commented 8 years ago

You may need to specify ephemeral port range in the from configure. Typically it is 49152-65535. And to port would be 8080, I think.

ChipHappens commented 8 years ago

@mawrew19 @bklavet I'm off to bed for the night. From the success I have had tonight, I'm looking forward to getting this working. Thanks again for all of the help!

ChipHappens commented 8 years ago

@bklavet you may have been right about a different network. I was still connected to wifi when trying from my phone.

Found this on an AT&T support page...

'When you tried running the client against it, were you in your home network still? If so, the public address won't work because the AT&T gateway will not do NAT loopback for you; you have to use the private address in your network."

ChipHappens commented 8 years ago

@bklavet @mawrew19 I tried using the WAN IP at work and it was a success; i got a call from my wife saying the DirecTV kept on pausing and playing lol

I'm going to try to implement the skill tonight! thanks again for all the help!

vmweaver commented 8 years ago

Awesome! lol. I should do that to my wife... she wouldn't be happy!

On Fri, May 20, 2016 at 12:29 PM, ChipHappens notifications@github.com wrote:

@bklavet https://github.com/bklavet @mawrew19 https://github.com/mawrew19 I tried using the WAN IP at work at it was a success; i got a call from my wife saying the DirecTV kept on pausing and playing lol

I'm going to try to implement the skill tonight! thanks again for all the help!

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/bklavet/Echo-skill-to-control-Directv/issues/2#issuecomment-220668448

bklavet commented 8 years ago

Good deal Chip!

ChipHappens commented 8 years ago

Got everything up and running tonight. I got a few bugs to iron out, but it's working for the most part. Thank you guys for all the help! This project has inspired me to jump into JavaScript and json programming. I already added intents to add changing channel by network name and channel number.

bklavet commented 8 years ago

Great deal Chip! throw out a you tube video and link it here! would be cool to see it in action!