Alexa和mysql远程端点不能被调用或者input无效

我正在尝试将alexa连接到mysql。 数据库通过xampp存储在本地主机上。 我已经完美地获得了nodejs-mysql连接,但是当我尝试将其与alexa合并在一起时,它就这样说

“远程端点不能被调用,或者它返回的响应是无效的。” 我的数据库文件: –

var mysql=require('mysql'); var con=mysql.createConnection({ host:'localhost', user: 'root', password:'', database:'ctp' }); function answer(){} answer.prototype.getdata= function(question,callback) { sql="select answer from jarvis where question="+question; con.query(sql,function(err,rows,fields) { callback(rows); }) } module.exports=answer; 

我的index.js文件: –

 'use strict'; var AlexaSkill = require('./AlexaSkill'), recipes = require('./recipes'), dbcon=require('./dbconfig'); var mys=new dbcon(); var APP_ID = "amzn1.ask.skill.1bfd2f06-1c46-464f-9f06-9195691e0aae"; //OPTIONAL: replace with 'amzn1.echo-sdk-ams.app.[your-unique-value-here]'; var HowTo = function () { AlexaSkill.call(this, APP_ID); }; // Extend AlexaSkill HowTo.prototype = Object.create(AlexaSkill.prototype); HowTo.prototype.constructor = HowTo; HowTo.prototype.eventHandlers.onLaunch = function (launchRequest, session, response) { var speechText = "Welcome to My Jarvis, version 1 point oh... How can I help you?"; // If the user either does not reply to the welcome message or says something that is not // understood, they will be prompted again with this text. var repromptText = "For instructions on what you can say, please say help me."; response.ask(speechText, repromptText); }; HowTo.prototype.intentHandlers = { "QuestionIntent": function (intent, session, response) { var itemSlot = intent.slots.Item, itemName,sp; if (itemSlot && itemSlot.value){ itemName = itemSlot.value.toLowerCase(); } sp=itemName; mys.getdata(sp,function(rows) { sp=rows; }); var cardTitle = "Details for " + itemName, //recipe=recipes[itemName], recipe = sp, speechOutput, repromptOutput; if (recipe) { //window.open("http://www.w3schools.com"); speechOutput = { speech: recipe, type: AlexaSkill.speechOutputType.PLAIN_TEXT }; response.tellWithCard(speechOutput, cardTitle, recipe); } else { var speech; speech = "There are no plans for you today"; } speechOutput = { speech: speech, type: AlexaSkill.speechOutputType.PLAIN_TEXT }; repromptOutput = { speech: "What else can I help with?", type: AlexaSkill.speechOutputType.PLAIN_TEXT }; response.ask(speechOutput, repromptOutput); }, "AMAZON.StopIntent": function (intent, session, response) { var speechOutput = "Goodbye"; response.tell(speechOutput); }, "AMAZON.CancelIntent": function (intent, session, response) { var speechOutput = "Goodbye"; response.tell(speechOutput); }, "AMAZON.HelpIntent": function (intent, session, response) { var speechText = "You can ask questions such as, what's the plan for today, or, you can say exit... Now, what can I help you with?"; var repromptText = "You can say things like, what's the plan for today, or you can say exit... Now, what can I help you with?"; var speechOutput = { speech: speechText, type: AlexaSkill.speechOutputType.PLAIN_TEXT }; var repromptOutput = { speech: repromptText, type: AlexaSkill.speechOutputType.PLAIN_TEXT }; response.ask(speechOutput, repromptOutput); } }; //what code do you want to see? exports.handler = function (event, context) { var howTo = new HowTo(); howTo.execute(event, context); }; 

我有两个sp分配,因为我想看看函数调用是否工作,以及它不,它只显示标识的itemName

所以看到以前的论坛,一些亚马逊帮手告诉我把lambda请求作为一个testing事件在lambda控制台,我试过了,并得到

 { "errorMessage": "RequestId: 7a56e239-d4cc-11e6-9671-cfba622fbaaf Process exited before completing request" } 

我想知道为什么alexa不会等待callback执行,并查询结果回sp和speechOutput,而且,context.done()/ succeed()如何帮助? 我试图将上下文对象传递给dbconfig文件,但它不工作。 你能告诉我一个解决scheme吗? 或至less提供alexa-mysql文件,如果它存在?