Skip to content

Instantly share code, notes, and snippets.

@AneilPatel05
Created June 8, 2018 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AneilPatel05/8cba8b914325ef9120516427558caa34 to your computer and use it in GitHub Desktop.
Save AneilPatel05/8cba8b914325ef9120516427558caa34 to your computer and use it in GitHub Desktop.
MQTT Basics Tutorial
//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())
})
@devangpa
Copy link

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 ........

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment