var mqtt = require('mqtt');
var lodash = require('lodash');
var client = mqtt.connect({ host: 'localhost', port: 1883 });
client.on('connect', function () {
console.log('Connected')
client.subscribe('presence');
});
client.on('message', function (topic, message) {
// message is Buffer
console.log(message.toString());
// remove the retained message
client.publish('presence', undefined, {retain: true});
});
Last active
December 25, 2023 20:38
-
-
Save anhldbk/71b6a377ada986aca63f5456a4192936 to your computer and use it in GitHub Desktop.
Remove MQTT retained messages using MQTT.js version 1.10.x
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks man, this saved me!