moscajs / mosca

MQTT broker as a module
mosca.io
3.2k stars 513 forks source link

Remove retained message from retained MongoDB collection #717

Closed robertsLando closed 6 years ago

robertsLando commented 6 years ago

Is there a way to remove a retained message from MongoDB collection using Mosca MQTT Broker?

robertsLando commented 6 years ago

Did it:

var topic = "/topic/to/remove/from/retained";
var qos = 1; //qos of retained packet

var message = {
    topic: topic
    payload: "",
    qos: qos,
    retain: true // or true
  };

  broker.publish(message, function(err) {
    if(err) console.log(err);
  });