Created
February 20, 2019 14:55
-
-
Save questsin/b94bf8ecf0fbf766a005e1f539a02b8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AWSMqtt = require('aws-mqtt-client').AWSMqtt; | |
//Create an IAM role and asign predefined AWSIoTDataAccess policy | |
const mqttClient = new AWSMqtt({ | |
accessKeyId: '', | |
secretAccessKey: '', | |
sessionToken: '', | |
endpointAddress: '', | |
region: 'eu-west-1' | |
}); | |
mqttClient.on('connect', () => { | |
mqttClient.subscribe('test-topic'); | |
console.log('connected to iot mqtt websocket'); | |
}); | |
mqttClient.on('message', (topic, message) => { | |
console.log(message.toString()); | |
}); | |
//mqttClient.publish(MQTT_TOPIC, message); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment