var mqtt = require('mqtt'); var settings = { clientId: "", //- username: "", // password: "" // }; var client = mqtt.connect("mqtt://mqtt.databoom.com:1883", settings); var post_data = { type: "data", message: { device: "", // signals: [{ name: "", // value: // }] } }; client.on('connect', function () { console.log(new Date().toISOString(), "\tCLIENT CONNECTED TO DATABOOM BROKER") client.subscribe(''); // nel formato d'esempio MQTT//info }); client.on('message', function (topic, message) { console.log(new Date().toISOString(), "\tDATA PUBLISHED ON", "MQTT//info"); console.log(message.toString()); }) client.publish("", JSON.stringify(post_data), function (err) { // nel formato d'esempio MQTT//data console.log(new Date().toISOString(), "\tDATA PUBLISHED ON", "MQTT//data"); console.log(JSON.stringify(post_data)); });