jovotech / jovo-framework

🔈 The React for Voice and Chat: Build Apps for Alexa, Messenger, Instagram, the Web, and more
https://www.jovo.tech
Apache License 2.0
1.68k stars 309 forks source link

Error when testing the skill #118

Closed ermalguni closed 6 years ago

ermalguni commented 6 years ago

Hi,

I am trying to run the helloworld project but jovo seems to have a problem. When I test from the test console I get: The requested skill took too long to respond

While the logs in the commandline show:


jovo run

Example server listening on port 3000!
This is your webhook url: https://webhook.jovo.cloud/160dd151-ac4d-488f-92da-93c522732efe
Unhandled Rejection at: Promise Promise {
  <rejected> Error: Something went wrong
    at IncomingMessage.res.on (/usr/local/lib/node_modules/jovo-cli/commands/run.js:153:28)
    at IncomingMessage.emit (events.js:185:15)
    at IncomingMessage.emit (domain.js:422:20)
    at endReadableNT (_stream_readable.js:1106:12)
    at process._tickCallback (internal/process/next_tick.js:178:19) } reason: Error: Something went wrong
    at IncomingMessage.res.on (/usr/local/lib/node_modules/jovo-cli/commands/run.js:153:28)
    at IncomingMessage.emit (events.js:185:15)
    at IncomingMessage.emit (domain.js:422:20)
    at endReadableNT (_stream_readable.js:1106:12)
    at process._tickCallback (internal/process/next_tick.js:178:19)
Unhandled Rejection at: Promise Promise {
  <rejected> Error: Something went wrong
    at IncomingMessage.res.on (/usr/local/lib/node_modules/jovo-cli/commands/run.js:153:28)
    at IncomingMessage.emit (events.js:185:15)
    at IncomingMessage.emit (domain.js:422:20)
    at endReadableNT (_stream_readable.js:1106:12)
    at process._tickCallback (internal/process/next_tick.js:178:19) } reason: Error: Something went wrong
    at IncomingMessage.res.on (/usr/local/lib/node_modules/jovo-cli/commands/run.js:153:28)
    at IncomingMessage.emit (events.js:185:15)
    at IncomingMessage.emit (domain.js:422:20)
    at endReadableNT (_stream_readable.js:1106:12)
    at process._tickCallback (internal/process/next_tick.js:178:19)```
ermalguni commented 6 years ago

Just to provide some more context on the error. After some debugging it looks like the local server is receiving HTML from a grafana dashboard instead of the JSON from Alexa.

jankoenig commented 6 years ago

Hi @ermalguni. Can you tell me more about the debugging you've done so far? Which operating system are you using?

ermalguni commented 6 years ago

Hi @jankoenig ,

OS: MacOSX 10.13.4 Node: v9.11.1 npm: 5.8.0

To find out about the HTML, I was debugging through VS Code. My Configuration is as follows:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Jovo",
            "cwd": "${workspaceFolder}",
            "program": "/usr/local/bin/jovo",
            "args": [
                "run"
            ]
        }
    ]
}
jankoenig commented 6 years ago

Thanks! Will take a look. cc @aswetlow

aswetlow commented 6 years ago

This happens when the response object is undefined. Could you post your 'LAUNCH' logic?

Could you also log the response object after you call tell or ask?

'LAUNCH': function() {
         this.tell('Hello World');
          console.log(this.getPlatform().getResponseObject());
}
ermalguni commented 6 years ago

My LAUNCH code is:

'LAUNCH': function() {
        this.tell(this.t("welcome"))
    }

I added the console log that you pasted but it is still the same. I got the same output. Anymore ideas?

aswetlow commented 6 years ago

What's in this.t("welcome") and what's in your app config?

ermalguni commented 6 years ago

That is a translation.

{
    "translation": {
        "welcome": "Hello from alexa"
    }
}

The app config is the default one:

const config = {
    logging: true,
};

The raw data that I get is

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width">
  <meta name="theme-color" content="#000">

  <title>Grafana</title>

  <base href="/" />

  <link rel="stylesheet" href="public/build/grafana.dark.css?v5.0.0-beta4">

  <link rel="icon" type="image/png" href="public/img/fav32.png">
  <link rel="mask-icon" href="public/img/grafana_mask_icon.svg" color="#F05A28">

</head>

<body ng-cloak class="theme-dark">
  <grafana-app class="grafana-app">

    <sidemenu class="sidemenu"></sidemenu>

    <div class="page-alert-list">
      <div ng-repeat='alert in dashAlerts.list' class="alert-{{alert.severity}} alert">
        <div class="alert-icon">
          <i class="{{alert.icon}}"></i>
        </div>
        <div class="alert-body">
          <div class="alert-title">{{alert.title}}</div>
          <div class="alert-text" ng-bind='alert.text'></div>
        </div>
        <button type="button" class="alert-close" ng-click="dashAlerts.clear(alert)">
          <i class="fa fa fa-remove"></i>
        </button>
      </div>
    </div>

    <div class="main-view">
      <div class="scroll-canvas" grafana-scrollbar>
        <div ng-view></div>

        <footer class="footer">
          <div class="text-center">
            <ul>
              <li>
                <a href="http://docs.grafana.org" target="_blank">
                  <i class="fa fa-file-code-o"></i>
                  Docs
                </a>
              </li>
              <li>
                <a href="https://grafana.com/services/support" target="_blank">
                  <i class="fa fa-support"></i>
                  Support Plans
                </a>
              </li>
              <li>
                <a href="https://community.grafana.com/" target="_blank">
                  <i class="fa fa-comments-o"></i>
                  Community
                </a>
              </li>
              <li>
                <a href="https://grafana.com" target="_blank">Grafana</a>
                <span>v5.0.0-beta4 (commit: 1de8891)</span>
              </li>

              <li>
                <a href="https://grafana.com/get" target="_blank" bs-tooltip="'5.0.0'">
                  New version available!
                </a>
              </li>

            </ul>
          </div>
        </footer>
      </div>
    </div>
  </grafana-app>

  <script>
    window.grafanaBootData = {
      user: {"isSignedIn":false,"id":0,"login":"","email":"","name":"","lightTheme":false,"orgCount":0,"orgId":0,"orgName":"","orgRole":"","isGrafanaAdmin":false,"gravatarUrl":"","timezone":"browser","locale":"en-US","helpFlags1":0},
      settings: {"alertingEnabled":true,"allowOrgCreate":false,"appSubUrl":"","authProxyEnabled":false,"buildInfo":{"buildstamp":1519046641,"commit":"1de8891","env":"production","hasUpdate":true,"latestVersion":"5.0.0","version":"5.0.0-beta4"},"datasources":{"-- Grafana --":{"meta":{"type":"datasource","name":"-- Grafana --","id":"grafana","info":{"author":{"name":"","url":""},"description":"","links":null,"logos":{"small":"public/img/icn-datasource.svg","large":"public/img/icn-datasource.svg"},"screenshots":null,"version":"","updated":""},"dependencies":{"grafanaVersion":"*","plugins":[]},"includes":null,"module":"app/plugins/datasource/grafana/module","baseUrl":"public/app/plugins/datasource/grafana","annotations":true,"metrics":true,"alerting":false,"builtIn":true,"routes":null},"name":"-- Grafana --","type":"datasource"},"-- Mixed --":{"meta":{"type":"datasource","name":"-- Mixed --","id":"mixed","info":{"author":{"name":"","url":""},"description":"","links":null,"logos":{"small":"public/img/icn-datasource.svg","large":"public/img/icn-datasource.svg"},"screenshots":null,"version":"","updated":""},"dependencies":{"grafanaVersion":"*","plugins":[]},"includes":null,"module":"app/plugins/datasource/mixed/module","baseUrl":"public/app/plugins/datasource/mixed","annotations":false,"metrics":true,"alerting":false,"queryOptions":{"minInterval":true},"builtIn":true,"mixed":true,"routes":null},"name":"-- Mixed --","type":"datasource"}},"defaultDatasource":"-- Grafana --","disableLoginForm":false,"externalUserMngInfo":"","externalUserMngLinkName":"","externalUserMngLinkUrl":"","googleAnalyticsId":"","ldapEnabled":false,"panels":{"alertlist":{"baseUrl":"public/app/plugins/panel/alertlist","hideFromList":false,"id":"alertlist","info":{"author":{"name":"Grafana Project","url":"https://grafana.com"},"description":"Shows list of alerts and their current status","links":null,"logos":{"small":"public/app/plugins/panel/alertlist/img/icn-singlestat-panel.svg","large":"public/app/plugins/panel/alertlist/img/icn-singlestat-panel.svg"},"screenshots":null,"version":"5.0.0","updated":""},"module":"app/plugins/panel/alertlist/module","name":"Alert List","sort":6},"dashlist":{"baseUrl":"public/app/plugins/panel/dashlist","hideFromList":false,"id":"dashlist","info":{"author":{"name":"Grafana Project","url":"https://grafana.com"},"description":"List of dynamic links to other dashboards","links":null,"logos":{"small":"public/app/plugins/panel/dashlist/img/icn-dashlist-panel.svg","large":"public/app/plugins/panel/dashlist/img/icn-dashlist-panel.svg"},"screenshots":null,"version":"5.0.0","updated":""},"module":"app/plugins/panel/dashlist/module","name":"Dashboard list","sort":7},"gettingstarted":{"baseUrl":"public/app/plugins/panel/gettingstarted","hideFromList":true,"id":"gettingstarted","info":{"author":{"name":"Grafana Project","url":"https://grafana.com"},"description":"","links":null,"logos":{"small":"public/app/plugins/panel/gettingstarted/img/icn-dashlist-panel.svg","large":"public/app/plugins/panel/gettingstarted/img/icn-dashlist-panel.svg"},"screenshots":null,"version":"","updated":""},"module":"app/plugins/panel/gettingstarted/module","name":"Getting Started","sort":100},"graph":{"baseUrl":"public/app/plugins/panel/graph","hideFromList":false,"id":"graph","info":{"author":{"name":"Grafana Project","url":"https://grafana.com"},"description":"Graph Panel for Grafana","links":null,"logos":{"small":"public/app/plugins/panel/graph/img/icn-graph-panel.svg","large":"public/app/plugins/panel/graph/img/icn-graph-panel.svg"},"screenshots":null,"version":"5.0.0","updated":""},"module":"app/plugins/panel/graph/module","name":"Graph","sort":1},"heatmap":{"baseUrl":"public/app/plugins/panel/heatmap","hideFromList":false,"id":"heatmap","info":{"author":{"name":"Grafana Project","url":"https://grafana.com"},"description":"Heatmap Panel for Grafana","links":[{"name":"Brendan Gregg - Heatmaps","url":"http://www.brendangregg.com/heatmaps.html"},{"name":"Brendan Gregg - Latency Heatmaps","url":" http://www.brendangregg.com/HeatMaps/latency.html"}],"logos":{"small":"public/app/plugins/panel/heatmap/img/icn-heatmap-panel.svg","large":"public/app/plugins/panel/heatmap/img/icn-heatmap-panel.svg"},"screenshots":null,"version":"5.0.0","updated":""},"module":"app/plugins/panel/heatmap/module","name":"Heatmap","sort":5},"pluginlist":{"baseUrl":"public/app/plugins/panel/pluginlist","hideFromList":false,"id":"pluginlist","info":{"author":{"name":"Grafana Project","url":"https://grafana.com"},"description":"Plugin List for Grafana","links":null,"logos":{"small":"public/app/plugins/panel/pluginlist/img/icn-dashlist-panel.svg","large":"public/app/plugins/panel/pluginlist/img/icn-dashlist-panel.svg"},"screenshots":null,"version":"5.0.0","updated":""},"module":"app/plugins/panel/pluginlist/module","name":"Plugin list","sort":100},"singlestat":{"baseUrl":"public/app/plugins/panel/singlestat","hideFromList":false,"id":"singlestat","info":{"author":{"name":"Grafana Project","url":"https://grafana.com"},"description":"Singlestat Panel for Grafana","links":null,"logos":{"small":"public/app/plugins/panel/singlestat/img/icn-singlestat-panel.svg","large":"public/app/plugins/panel/singlestat/img/icn-singlestat-panel.svg"},"screenshots":null,"version":"5.0.0","updated":""},"module":"app/plugins/panel/singlestat/module","name":"Singlestat","sort":2},"table":{"baseUrl":"public/app/plugins/panel/table","hideFromList":false,"id":"table","info":{"author":{"name":"Grafana Project","url":"https://grafana.com"},"description":"Table Panel for Grafana","links":null,"logos":{"small":"public/app/plugins/panel/table/img/icn-table-panel.svg","large":"public/app/plugins/panel/table/img/icn-table-panel.svg"},"screenshots":null,"version":"5.0.0","updated":""},"module":"app/plugins/panel/table/module","name":"Table","sort":3},"text":{"baseUrl":"public/app/plugins/panel/text","hideFromList":false,"id":"text","info":{"author":{"name":"Grafana Project","url":"https://grafana.com"},"description":"","links":null,"logos":{"small":"public/app/plugins/panel/text/img/icn-text-panel.svg","large":"public/app/plugins/panel/text/img/icn-text-panel.svg"},"screenshots":null,"version":"5.0.0","updated":""},"module":"app/plugins/panel/text/module","name":"Text","sort":4}}},
      navTree: [{"id":"dashboards","text":"Dashboards","subTitle":"Manage dashboards \u0026 folders","icon":"gicon gicon-dashboard","url":"/","children":[{"id":"home","text":"Home","icon":"gicon gicon-home","url":"/","hideFromTabs":true},{"id":"divider","text":"Divider","divider":true,"hideFromTabs":true},{"id":"manage-dashboards","text":"Manage","icon":"gicon gicon-manage","url":"/dashboards"},{"id":"playlists","text":"Playlists","icon":"gicon gicon-playlists","url":"/playlists"},{"id":"snapshots","text":"Snapshots","icon":"gicon gicon-snapshots","url":"/dashboard/snapshots"}]},{"id":"help","text":"Help","icon":"gicon gicon-question","url":"#","hideFromMenu":true,"children":[{"text":"Keyboard shortcuts","icon":"fa fa-fw fa-keyboard-o","url":"/shortcuts","target":"_self"},{"text":"Community site","icon":"fa fa-fw fa-comment","url":"http://community.grafana.com","target":"_blank"},{"text":"Documentation","icon":"fa fa-fw fa-file","url":"http://docs.grafana.org","target":"_blank"}]}]
    };
  </script> 

<script type="text/javascript" src="public/build/manifest.b38a2b5aab572fb68f0d.js"></script><script type="text/javascript" src="public/build/vendor.d7e63bf50de0f47510a6.js"></script><script type="text/javascript" src="public/build/app.60ba32afcd4988f28a15.js"></script></body>

</html>

The part of the code that it is failing is, run.js:

let req = http.request(opt, (res) => {
            res.setEncoding('utf8');
            let rawData = '';
            res.on('data', (chunk) => {
                rawData += chunk;
            });
            res.on('end', () => {
                let parsedData;
                try {
                    parsedData = JSON.parse(rawData);
                } catch (e) {
                    reject(new Error('Something went wrong'));
aswetlow commented 6 years ago

We don't use Grafana anywhere :) Is an instance running on localhost:3000?

ermalguni commented 6 years ago

Hmmmmm, that is weird. I just found out to have a docker container with grafana in port 3000. I would have expected node to have thrown an exception. Now everything works fine. I would suggest to document this issue in case another dev runs into this error.

Thanks a lot for the help. I am closing this issue now.

aswetlow commented 6 years ago

I'm glad it helped. Btw: You can use another port: 1) Change port from 3000 to whatever in index.js in your project. 2) jovo run --port XXX