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
gefragt vor 4 Jahren185 Aufrufe
1 Antwort
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
beantwortet vor 4 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen