Created
December 13, 2018 12:29
-
-
Save developeryashraj/54fa0ee5825ff13544dbb719a06a8215 to your computer and use it in GitHub Desktop.
MQTT node cluster with redis
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
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