alexa / alexa-skills-kit-sdk-for-nodejs

The Alexa Skills Kit SDK for Node.js helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
Apache License 2.0
3.12k stars 737 forks source link

Want to publish data on aws iot with alexa using aws-iot-device-sdk and ask-sdk in lambda #611

Closed shubhamsbhosale96 closed 4 years ago

shubhamsbhosale96 commented 4 years ago

I have provided my lambda code file below and I wanted to add aws-iot-device-sdk in it so where should i write the function awsIot.device function in code. when I write it at start of the code, I was getting an error as

Response: { "errorMessage": "2020-02-21T10:53:02.615Z c574f829-1f9e-47d0-bcb7-4437def75a1e Task timed out after 3.00 seconds" }

Request ID: "c574f829-1f9e-47d0-bcb7-4437def75a1e"

Function Logs: START RequestId: c574f829-1f9e-47d0-bcb7-4437def75a1e Version: $LATEST END RequestId: c574f829-1f9e-47d0-bcb7-4437def75a1e REPORT RequestId: c574f829-1f9e-47d0-bcb7-4437def75a1e Duration: 3003.26 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 102 MB Init Duration: 563.76 ms
2020-02-21T10:53:02.615Z c574f829-1f9e-47d0-bcb7-4437def75a1e Task timed out after 3.00 seconds

So give me an answer for adding aws-IoT with alexa skill kit version 2.7.0

code.txt

ShenChen93 commented 4 years ago

Hi @shubhamsbhosale96

Thanks for reaching out. The place you create IotClient and make the function call looks good to me. Thus I guess the root cause is from the usage of IOT SDK.

Cause I don't have any experience of using aws-iot-device-sdk, thus I reach to their team for help. Here is the concerns I got from them: (1) They are using a fixed client ID for their mqtt connection. This will break horribly the second they have two instances of their lambda running simultaneously (missing data if lucky, disconnect/reconnect infinite loop if not lucky). (2) Their call to device.publish() appears to not use the right function signature and has the callback as the third parameter rather than the fourth parameter. I don't know JS, but if this is an error, then their callback will never get invoked. Since their callback is where they close their long-lived mqtt connection, that would never happen and the lambda would run forever (until the service shuts it down).

Since It's not ASK-SDK's problem, I will close this issue from our side. You could reach out to aws-iot-device-sdk's repo for help, and please feel free to reopen this issue if you believe the root cause is from our side.