Comments (15)
Can you not use pub.retain()?
from pubsubclient.
Where is that defined? I can't find it in PubSubClient.h
from pubsubclient.
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.
@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.
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.
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.
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.
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.
So you mean that a retained message is stored on the server harddisk and it remains on the hdd indefinitely ?
from pubsubclient.
It depends on broker's implementation but it seems to be done that way by mosquitto.
from pubsubclient.
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.
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.
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.
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.
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)
- Subscribe to two topics?
- Compatibility broken with original knolleary/pubsubclient lib HOT 1
- Wrong password HOT 3
- lib update installs the knolleary lib HOT 4
- Message published multiple times HOT 1
- MAX transfer size is not found
- more than one Nodemcu clients can't able to get published message at a time HOT 1
- Multiple unsubscribe or publish with QoS 1 in callback HOT 1
- How to set the callback from a c++ class? HOT 1
- wrong hostname used
- esp12F heating issue HOT 1
- socket error
- ESP32 HOT 1
- Memory leak on loop() HOT 1
- can this library subscribe to mqtt topic ? HOT 1
- error "MQTT' does not name a type" when compiling ESP8266-OTA example HOT 1
- PubSubClient.connect with userName/password ? HOT 1
- control reaches end of non-void function HOT 1
- beebotte.com - retain vs write API (weird persistance, possible to add) - not a bug I think
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pubsubclient.