Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use this SDK with ngrok or a local host #73

Closed
nemr opened this issue Mar 13, 2017 · 8 comments
Closed

How to use this SDK with ngrok or a local host #73

nemr opened this issue Mar 13, 2017 · 8 comments

Comments

@nemr
Copy link

nemr commented Mar 13, 2017

hello ,
How can I use this npm with ngrok instead of using it with AWS lambda ? where ngrok tunnels the local host to a secure public ip HTTPS.

@ghost
Copy link

ghost commented Mar 21, 2017

You could support local testing by creating an express wrapper around the handler function.
If you had an index.js which the following code:

var Alexa = require('alexa-sdk');

exports.handler = function(event, context, callback){
    var alexa = Alexa.handler(event, context);
};

You could then create a file called local.js which creates an express app that calls the handler function and returns the result.

I did something like this a few weeks ago to facilitate local testing for a skill but the solution is not ideal because the Lambda Context object needs to be mocked (it's passed in as a parameter to the Alexa handler function).

With a bit more work, and some changes to the SDK, we could easily facilitate this. In the meantime, the work-around i described above would work.

@ericblade
Copy link

Potentially relevant alexa-js/alexa-app-server#13

@ghost
Copy link

ghost commented Apr 6, 2017

Running a test on localhost through TLS to an HTTPS connection over open web poses security risks. The local web server that ngrock is running will not contain a key/certificate pair, which is required for transport layer security (TLS) connection to an authenticated server. You can still connect, using the insecure parameter with the curl command, but you will not be using a hypertext transfer protocol with an encrypted connection, opening multiple vectors to the attack surface of your computer. Since you're planning on tunneling to an HTTPS site, I'm going to assume that's where your service for your actions are hosted, and you've configured them to respond properly once you make the request to the service.

If it were me, and you have your service hosted on a server that supports TCP tunneling, (and you don't have the auth credentials for full TLS) I would make sure that the server is accepting incoming connections on port 22 from the public IP address of your computer, and test invoking my actions through the SSH tunnel. I have no idea if a TCP tunnel would even work, it's just speculative opinion after reading through some documentation. You'd have to test that on your own.

As stated above, the Alexa Skills SDK and AWS Lambda are a perfect architecture match. It would be much easier, at this current state in the development process, to engineer your cloud services for an AWS Lambda. Good luck.

Edit: Spelling

@ghost ghost closed this as completed Apr 7, 2017
@eljefedelrodeodeljefe
Copy link

I think this should be re-opened, since at least @bclement-amazon proceedings could be documented. Following the Alexa docs, choosing https over Lambda basically get you stuck here.

@eljefedelrodeodeljefe
Copy link

To be precise: the issue should not be around the tunnel, but local development or https routing to wrap Lambda event and context, since this is what his hindering users.

@mlopezr
Copy link

mlopezr commented Nov 2, 2017

Here's a repo showing how to create the Express wrapper around a skill to run it locally:
https://github.com/Glogo/alexa-skill-sample-nodejs-express

@dly9014
Copy link

dly9014 commented Dec 27, 2017

I posted an approach to doing this up at the SO question noted above

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants