Skip to content

Instantly share code, notes, and snippets.

@developeryashraj
Created December 13, 2018 12:29
Show Gist options
  • Save developeryashraj/54fa0ee5825ff13544dbb719a06a8215 to your computer and use it in GitHub Desktop.
Save developeryashraj/54fa0ee5825ff13544dbb719a06a8215 to your computer and use it in GitHub Desktop.
MQTT node cluster with redis
let config = {
"mqtt": {
"port": 1883,
"http_port": 1884
}
};
//https://github.com/mcollina/ascoltatori
var ascoltatore = {
type: 'redis',
redis: require('redis'),
db: 12,
port: 6379,
return_buffers: true, // to handle binary payloads
host: 'localhost'
};;
//create connection settings for MQTT
let settings = {
port: config.mqtt.port,
backend: ascoltatore,
stats: false,
logger: {},
http: {
port: config.mqtt.http_port,
bundle: true
}
};
let mqttServer = new mosca.Server(settings);
mqttServer.on('ready', setup);
function setup() {
console.log('Mosca(mqttt) server is up and running.....', settings.port);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment