alexa-js / alexa-app-server

An Alexa app server for alexa-app.
MIT License
401 stars 116 forks source link

Server doesn't appear to be starting... #94

Closed rwillett closed 7 years ago

rwillett commented 7 years ago

Hi,

Thanks for the framework, we're trying to get the example working on our own Ubuntu 16.04 server and are struggling.

Our test environment is ubuntu 16.04, we've patched it so it has all the current updates.

We've taken the code examples from this website and basically copied them to the same directory structure. We have some simple skills working under Amazon but we want to host the skills server ourselves as we need to query a large database and we want to know how to do it. We figure we'll start small and incrementally build.

We have created the sample server.js, the simple hello world app, we've added in a genuine and up to date wildcard certificate from RapidSSL. We have also added in the other files as needed so that our directory resembles the example structure.

We then try to start the server up by typing

nodejs server.js
serving static content from: /jambuster/alexa/public_html
loading server-side modules from: /jambuster/alexa/server
   loaded /jambuster/alexa/server/login.js
loading apps from: /jambuster/alexa/apps
   loaded app [Jambuster] at endpoint: /alexa/hello_world
enabling https
using chain certificate from /jambuster/alexa/sslcert
listening on https port 443
listening on http port 8080

but there's no server actually listening on either port 443 or port 8080.

netstat -plnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      357/sshd
tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN      409/nginx -g daemon
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      629/master
tcp        0      0 0.0.0.0:4000            0.0.0.0:*               LISTEN      409/nginx -g daemon
tcp        0      0 195.181.242.57:11300    0.0.0.0:*               LISTEN      348/beanstalkd
tcp6       0      0 :::4001                 :::*                    LISTEN      640/nodejs

We use nodejs for another project that sits on port 4001 so we know that it can work, but we're not experts in nodejs.

We can't see any errors, we've turned on debugging in the server.js file

var AlexaAppServer = require('alexa-app-server');

var instance = AlexaAppServer.start({
    server_root: __dirname ,     // Path to root
    public_html: "public_html", // Static content
    app_dir: "apps",            // Location of alexa-app modules
    // app_root: "/alexa/",        // Service root
    app_root: "alexa",        // Service root
    port: 8080 ,                 // Port to use
    server_dir: 'server',
    httpEnabled: true,
    log: true,

    // Enable https support. Note httpsPort, privateKey, and certificate are required.
    // Default is false.
    httpsEnabled: true,

    // The https port the server will bind to. Required for httpsEnabled support.
    // Default is undefined.
    httpsPort: 443,

    // The private key filename. This file must reside in the sslcert folder under the
    // root of the project.
    // Default is undefined.
    privateKey: 'private-key.pem',

    // The certificate filename. This file must reside in the sslcert folder under the root of the
    // project.
    // Default is undefined.
    certificate: 'cert.cer',

    // The certificate chain bundle filename. This is an optional file that must reside in the
    // sslcert folder under the root of the project.
    // Default is undefined.
    chain: 'cert.ca_bundle',
});

instance.stop();              // Stop the server

The app itself is pretty simple

var alexa = require('alexa-app');

// Allow this module to be reloaded by hotswap when changed
module.change_code = 1;

// Define an alexa-app
var app = new alexa.app('hello_world');
app.id = require('./package.json').alexa.applicationId;

app.launch(function(req, res) {
  res.say("Hello World!!");
});

app.intent('NameIntent', {
  "slots": { "NAME": "LITERAL", "AGE": "NUMBER" },
  "utterances": ["{My name is|my name's} {matt|bob|bill|jake|nancy|mary|jane|NAME} and I am {1-100|AGE}{ years old|}"]
}, function(req, res) {
  res.say('Your name is ' + req.slot('NAME') + ' and you are ' + req.slot('AGE') + ' years old');
});

app.intent('AgeIntent', {
  "slots": { "AGE": "NUMBER" },
  "utterances": ["My age is {1-100|AGE}"]
}, function(req, res) {
  res.say('Your age is ' + req.slot('AGE'));
});

module.exports = app;

Our version of node seems up to date

nodejs -v
v4.2.6

We have read the docs but we can't find a single instance of a command line invocation of server.js. We only want to get it working once and we'll probably speed along, but sadly we seem to be stuck. I suspect we're being dumb, but after looking at this for the last four hours we're asking for help. At the moment, not making a connection is the problem. Thanks

Rob

rwillett commented 7 years ago

After a lot of reading it appears that we need to add more code in. We had thought the examples on the readme.md were sufficient, but after loading in index.js we now have a server.js which returns something, not got intents working yet, but its early days.

ericblade commented 7 years ago

The line "instance.stop()" ends your server immediately after it begins.

Also, node is on 8.1 :-)

rwillett commented 7 years ago

Ahhhhhhhhhh........ We misunderstood what that line does.

Node on Ubuntu 16.04 is still down at v4.2.6. Ubuntu is a complete PITA when it comes to versions. I know they want a standard version for Long Term Support but it is a long way out of date, mind you, V4.6.2 does work for us.

We're going to have another crack at this later tonight out of working hours as we have other things to do. We do have one other question:

  1. Does this server handle all the security interactions from Amazon about verifying that Amazon is making the call, e.g.

https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/developing-an-alexa-skill-as-a-web-service#Checking%20the%20Signature%20of%20the%20Request

or do we need to do something like

https://www.npmjs.com/package/alexa-verifier

Thanks very much

Rob

ericblade commented 7 years ago

When you set debug false and verify true it should handle everything.

On Jul 17, 2017 12:25 PM, "Rob Willett" notifications@github.com wrote:

Ahhhhhhhhhh........ We misunderstood what that line does.

Node on Ubuntu 16.04 is still down at v4.2.6. Ubuntu is a complete PITA when it comes to versions. I know they want a standard version for Long Term Support but it is a long way out of date, mind you, V4.6.2 does work for us.

We're going to have another crack at this later tonight out of working hours as we have other things to do. We do have one other question:

  1. Does this server handle all the security interactions from Amazon about verifying that Amazon is making the call, e.g.

https://developer.amazon.com/public/solutions/alexa/alexa- skills-kit/docs/developing-an-alexa-skill-as-a-web-service# Checking%20the%20Signature%20of%20the%20Request

or do we need to do something like

https://www.npmjs.com/package/alexa-verifier

Thanks very much

Rob

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/alexa-js/alexa-app-server/issues/94#issuecomment-315797908, or mute the thread https://github.com/notifications/unsubscribe-auth/ABYnR7FMXtI212-QoSBr5xN3M0-anXgCks5sO4mygaJpZM4OZYBH .

rwillett commented 7 years ago

Thanks. We have a server running, we will keep reading and learning.

We'll get it working with Paw and the graduate to AWS.

Much appreciate the support

Rob