smart home iot thing trouble publishing from lambda to iot thing

0

If i test publish to my iot thing inTopic from MQTT, it works fine. When I try and publish from lambda i get nothing. I am stumped. What can I check?
Here is a snippet of my lambda publish code:

var config = {
  "thingName": 'garageThing',
  "endpointAddress": "@@@@@@@@@@-ats.iot.us-east-1.amazonaws.com",
  "region": "us-east-1"
};
 
function publish() {
  console.log("in publish");
  var params = {
    topic: 'inTopic',
    payload: 'Hello from lambda',
    qos: 0
  };
 
  var iotData = new AWS.IotData({endpoint: config.endpointAddress});
  iotData.publish(params, function(err, data) {
    console.log("in publish callback");
    if(err){
        console.log(err);
    }
    else{
        console.log("\nSuccess, I guess.\n");
        //context.succeed();
    }
  });
}
h16bill
질문됨 4년 전186회 조회
1개 답변
0

Turns out it was a callback timing issue. I painfully started with a working example and converted it a few lines at a time until it started failing. Then it was obvious.

h16bill
답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인