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
asked 3 years ago14 views
1 Answer
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
answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions