-
-
Save tuannguyenssu/3d87cb7445e5d83154340597c88ef63a 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 mqtt = require('mqtt'); | |
var settings = { | |
mqttServerUrl : "localhost", | |
port : 18833, | |
topic : "myTopic" | |
} | |
var client = mqtt.connect('mqtt://' + settings.mqttServerUrl + ":" + settings.port); | |
client.on('connect', function () { | |
setInterval(function() { | |
var message = "Hello mqtt"; | |
client.publish(settings.topic, message); | |
console.log('Sent ' + message + " to " + settings.topic); | |
}, 1000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment