简体   繁体   English

无法调用远程端点,或者它返回的响应无效。 (alexa,aws)

[英]The remote endpoint could not be called, or the response it returned was invalid. (alexa, aws)

I'm currently getting into developing alexa-skills. 我目前正在开发alexa技能。 This is in fact the 1st time I'm trying this and I kinda works out good so far. 实际上,这是我第一次尝试这种方法,到目前为止效果还不错。 However, I stumbled upon a problem which seems to be wide-spreaded but I couldn't find an answer how to solve it. 但是,我偶然发现了一个似乎广泛传播的问题,但找不到解决方案。

First things first: I started this skill by following a tutorial . 首先,第一件事:我通过学习教程开始了这项技能。 It might be that this tutorial is outdated and therefore this error appears. 该教程可能已过时,因此出现此错误。

I created a skill from the scratch and it works to the part where the LaunchRequest is invoked: 我从头开始创建了一项技能,该技能可用于调用LaunchRequest的部分:

在此处输入图片说明

As you can see, I get my response as expected. 如您所见,我得到了预期的答复。 (works on the test-environment as well as on alexa itself). (适用于测试环境以及Alexa本身)。 Now, when try to call an IntentRequest , I just get the error-message: 现在,当尝试调用IntentRequest ,我仅收到错误消息:

The remote endpoint could not be called, or the response it returned was invalid. 无法调用远程端点,或者它返回的响应无效。

在此处输入图片说明

As I can tell from the picture / request, the correct intent-request is called (in my case getSubscriberCount ) - And this is the point where I have no idea anymore on how to resolve this problem. 从图片/请求可以看出,调用了正确的intent-request(在我的情况下为getSubscriberCount )-这是我不再了解如何解决此问题的要点。

To keep things short, this here is the JS-part for the Intent: 为了简短起见,这是Intent的JS部分:

case "IntentRequest": // Intent Request console.log( INTENT REQUEST ) 案例“ IntentRequest”:// Intent Request console.log( INTENT REQUEST

    switch(event.request.intent.name) {
        case "GetSubscriberCount":
            var endpoint = "my url"
            var body = ""
            https.get(endpoint, (response) => {
                response.on('data', (chunk) => { body += chunk })
    response.on('end', () => {
        var data = JSON.parse(body)
        var subscriberCount = data.items[0].statistics.subscriberCount
        context.succeed(
        generateResponse(
            buildSpeechletResponse(`Du hast momentan ${subscriberCount} Abonnenten`, true),
            {}
        )
    )

And this is causing my problems. 这就是我的问题。 To test what exactly is wrong, I tried the following: 为了测试到底是什么错误,我尝试了以下操作:

  • Called the endpoint in my browser --> Correct output 在浏览器中调用了端点->正确的输出
  • Adjusted the "response" to the minimum to see if that works --> didn't work 将“响应”调整为最小,以查看是否有效->无效
  • Checked several sources related to this error --> didn't help either 检查了与此错误相关的多个来源->都没有帮助

I saw some approaches to get rid of this, since this seems to be a common issue, but I got lost. 我看到了一些摆脱这种情况的方法,因为这似乎是一个常见问题,但是我迷路了。 Someone mentioned an environment variable, which I couldn't put my hands on. 有人提到了一个环境变量,我无法动手。 Another one suggested to run the JSON request manually, which I tried, but leading to the same error. 另一个建议手动运行JSON请求,我尝试过,但导致相同的错误。

Hopefully you can help me out here. 希望你能在这里帮助我。

假设您使用的是AWS lambda,可能是因为您没有创建响应权限,或者您的AWS lambda函数出现错误。

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

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