Created
June 8, 2018 19:02
-
-
Save AneilPatel05/8cba8b914325ef9120516427558caa34 to your computer and use it in GitHub Desktop.
MQTT Basics Tutorial
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
//Publisher.js | |
var mqtt = require('mqtt') | |
var client = mqtt.connect('mqtt://test.mosquitto.org') | |
client.on('connect', function () { | |
setInterval(function(){client.publish('topic', 'Hello mqtt')},1000) | |
}) | |
//Subscriber.js | |
var mqtt = require('mqtt') | |
var client = mqtt.connect('mqtt://test.mosquitto.org') | |
client.on('connect', function () { | |
client.subscribe('mytopic'); | |
}) | |
client.on('message', function (topic, message) { | |
console.log(message.toString()) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey , @AneilPatel i want to know i have a one publisher device that constantly send a data i need to make a front end from that as well as i need to save the data from that device . using node js is it possible ? Make A API ?any suggestion you can to gave me ........