MQTT in AWS Lambda function for Alexa Javascript -


please help, need use mqtt protocol in lambda function send data broker. use simple code test :

mqtt = require('mqtt'); var client  = mqtt.connect('mqtt://test.mosquitto.org');  client.on('connect', function () {   client.subscribe('presence');   client.publish('presence', 'hello mqtt'); });  client.on('message', function (topic, message) {   // message buffer    console.log(message.tostring());   client.end(); }); 

but error "cannot find module 'mqtt'", how can include module in lambda function??? how can use mqtt in lambda anyways?? somebody???

first in directory of project:

npm install mqtt --save  

after zip folder (inside folder, files , subdirectories) , upload lambda function.

every time must create handler function, create function this:

exports.handler  = function (event, context, callback) { ... code...  } 

in lambda function @ aws panel appoint file , function using in handler text field.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -