My MQTT.js client is unable to receive all messages from Mosquitto broker, due to constant disconnect/reconnects. When adding the option clean: false
to publish and subscribe, the client stops receiving messages altogether. I've tried all settings of qos
, with no success. I think I'm using the cleanSession improperly, does anybody know?
My configuration is as follows:
var options = {
clientId: "python_pub",
clean: false,
qos: 2
};
// connect to the message server
var client = mqtt.connect('mqtt://PATH_TO_BROKER', options);
client.on('connect', function() {
client.subscribe('topic_name');
})
client.on('message', function(topic, message) {
console.log("received: %s", message);
}
var count = 0;
while (count < 100) {
client.publish('test_topic', count.toString(), {qos: 2});
count++;
}