Closed helpme1 closed 7 years ago
You mean something like
moscaSettings = {
host: "<ip>"
,port: "<port>"
........
,persistence : {
factory : mosca.persistence.Memory
}
};
Got the same question. Can I use pure Mosca without Mosquitto or Redis or the like? Just in-memory?
Yes, with the above configuration. I run it like that with no issues.
Here is working sample code that I wrote myself.
var mosca = require('mosca')
var settings = {
port: 1883,
};
var server = new mosca.Server(settings);
server.on('ready', setup);
server.on('clientConnected', function(client) {
console.log('client connected', client.id);
});
// fired when a message is received
server.on('published', function(packet, client) {
console.log('Published', packet.payload);
});
// fired when the mqtt server is ready
function setup() {
console.log('Mosca server is up and running')
}
From the documentation, it seems that embedded mosca has to use an external broker such as Mosquitto, AMQP, ZeroMQ, Redis. For stand-alone mosca, no external broker is required. Can an embedded mosca be run such that no external broker is used similar to stand-alone mosca?
If this can be done, how should the code that uses redis below be modified?