Git Product home page Git Product logo

Comments (15)

Imroy avatar Imroy commented on July 4, 2024

Can you not use pub.retain()?

from pubsubclient.

newtovaux avatar newtovaux commented on July 4, 2024

Where is that defined? I can't find it in PubSubClient.h

from pubsubclient.

Imroy avatar Imroy commented on July 4, 2024

It'll be in MQTT.h, in the 'Message' base class. As I explain in the README, I added a set of classes for the MQTT messages and PubSubClient is mostly just a wrapper.

from pubsubclient.

capedra avatar capedra commented on July 4, 2024

@Imroy
I've been having a 'retain' struggle on ESP8266-OTA implementation. The messages aren't getting retained on my own broker. Sometimes it retains but sometimes it doesn't. I've already changed qos to 1 and 2 but this issue persists. Maybe because the body of the message is empty? I'm still trying to find out the reason why.

from pubsubclient.

capedra avatar capedra commented on July 4, 2024

The publish function returns true and I already tried the following lines but this issue still happens:

if (mqtt_client.publish(pub.topic(), (uint8_t*) "", 0, true))
   Serial.println("Published!");

Also:

if (mqtt_client.publish(MQTT::Publish(pub.topic(), "").set_retain().set_qos(1)))
   Serial.println("Published!");

from pubsubclient.

Altair31 avatar Altair31 commented on July 4, 2024

Maybe because the body of the message is empty?

A retained topic with empty message means clear this retained topic (if any).
Can you try to set a payload to your message?

from pubsubclient.

Testato avatar Testato commented on July 4, 2024

Is the retained message stored in Ram ? If I reboot the broker I will loose the message ?

Sorry for the semi-ot, but on my mosquitto broker the retained message work, but after some days/weeks the retained messages is lost (I do not know what happens, i see only all the clients without message)

from pubsubclient.

Altair31 avatar Altair31 commented on July 4, 2024

No, I use mosquitto with my home-made IOT without problems (and I also use retained messages).
Can you check with another software like paho?

from pubsubclient.

Testato avatar Testato commented on July 4, 2024

So you mean that a retained message is stored on the server harddisk and it remains on the hdd indefinitely ?

from pubsubclient.

Altair31 avatar Altair31 commented on July 4, 2024

It depends on broker's implementation but it seems to be done that way by mosquitto.

from pubsubclient.

capedra avatar capedra commented on July 4, 2024

Is the retained message stored in Ram ? If I reboot the broker I will loose the message ?

According to the MQTT protocol, servers can, theoretically, keep retained messages forever, although sometimes there's a limit set by the broker's configuration. Consider, for example, RabbitMQ, which has a 24 hours retention limit by default, even though you can customize this configuration at anytime on it.
I've been using Mosquitto on DO (DigitalOcean), and I even tried to reboot the server but the retention is maintained intact after it.

from pubsubclient.

capedra avatar capedra commented on July 4, 2024

Can you try to set a payload to your message?

Yeah, I've been trying with different payloads but, sometimes, the broker does not get the published message from the Wemos D1 Mini Pro.
UPDATE: current version of mosquitto's broker: 1.4.8.
I will be doing some tests on the version 1.4.14 which fixes some issues related to persistent data.

from pubsubclient.

Testato avatar Testato commented on July 4, 2024

But 1.4.14 fix a regression on .13 version, so your .8 version should be non affected.

Some of you have retained message that do not change for very long time ? For example have some of you a retained message stored 6 months ago or 1 year ago ?

from pubsubclient.

capedra avatar capedra commented on July 4, 2024

But 1.4.14 fix a regression on .13 version, so your .8 version should be non affected.

You're right. Unfortunately, the persistent data issue persists on 1.4.14.
UPDATE: I think I know what's going on, but, just to make sure, I will do a zillion tests more before posting the results here.

from pubsubclient.

Booli avatar Booli commented on July 4, 2024

So did you ever figure this out?
I have a problem with the OTA sketch example where the message to clear the update is not send (so from the ESP8266), making the ESP8266 either go into a loop or just hang on it's face after reboot.
I put an if() around the publish and indeed sometimes it just does not publish the message.

Tried QoS 1 and 2, but both to no avail. I suspect it just fails to send it in a first try and then straight after the example sketch just disconnects the client.

I would like to reliably use this to update multiple ESP8266 in the field by MQTT, but I'm stuck on this.

from pubsubclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.