Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
var mqtt = require('mqtt');
var client1 = mqtt.connect('mqtt://');
var client2 = mqtt.connect('mqtt://');
client1.on('connect', function () {
client1.on('message', function (topic, message) {
console.log("got msg", topic, message.toString());
client1.on("error", (e) => console.error(e));
client2.on("error", (e) => console.error(e));
setInterval(() => client2.publish("foo", "bar"), 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment