简体   繁体   English

自定义意图上的 AWS lambda 超时

[英]AWS lambda timeout on custom intents

I am building an Amazon Alexa skill that gets data async from Google's Firebase.我正在构建一个从 Google 的 Firebase 获取异步数据的 Amazon Alexa 技能。

When I run the Lambda function locally and call it from my Alexa skill all intents work as expected.当我在本地运行 Lambda 函数并从我的 Alexa 技能调用它时,所有意图都按预期工作。

However when I zip up the files (not the folder) and move it to AWS lambda the function times out even thought the data has been received and the response object created as expected.但是,当我压缩文件(而不是文件夹)并将其移动到 AWS lambda 时,即使认为已收到数据并且按预期创建了响应对象,该函数也会超时。

The built in intents are all working as expected too内置的意图也都按预期工作

My code is on GitHub here我的代码在 GitHub 上

The error log and console.log outputs 错误日志和 console.log 输出

I have tried to find any solutions via here and google but no luck.我试图通过这里和谷歌找到任何解决方案,但没有运气。 It could be that I have been searching the wrong things or this is a specific problem可能是我一直在寻找错误的东西,或者这是一个特定的问题

Resource 资源

When using firebase with lambda it would appear that you need to initalize and then delete the instance for the response to be returned.将 firebase 与 lambda 一起使用时,您似乎需要初始化然后删除要返回的响应的实例。

this is a code snippit that I got to work这是我开始工作的代码片段

const Alexa = require("ask-sdk");
const firebase = require("firebase");

var config = {
  ...
};

const GetOrderIntent = {
  canHandle(handlerInput) {
    const request = handlerInput.requestEnvelope.request;
    return (
      request.type === "IntentRequest" &&
      request.intent.name === "GetOrderIntent"
    );
  },
  async handle(handlerInput) {
    firebase.initializeApp(config);

    try {
      const store = await firebase
        .database()
        .ref(`teams/${team}`)
        .once("value");
      // ANY OTHER CODE HERE
   } catch (error) {
      // HANDLE ERROR
    }
    // CLOSE THE CONNECTION
    await firebase.app("[DEFAULT]").delete();
    return handlerInput.responseBuilder
      .speak(speechOutput)
      .withSimpleCard(SKILL_NAME, speechOutput)
      .getResponse();
  }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM