Comments (10)
I just released a new version with the new methods included. The duplicated ID is now cleared after every publish, successful or not.
from arduino-mqtt.
Just a follow up. If you think that storing the last message ID sent per topic is too costly. It would be nice to atleast have another onpublish method like this:
bool publish(const String &topic, const String &payload, bool retained, int qos, unsigned int * messageId, bool duplicate)
The function can return true if the publish was successful or false if it failed. But also it can inform the user the message ID used for publishing that message storing it in the pointer messageID passed. Then my program could be sent again the same message passing duplicate to TRUE and the message ID.
What do you think?
from arduino-mqtt.
I have created a pull request adding this functionality to lwmqtt first.
from arduino-mqtt.
I added the experimental methods uint16_t lastPacketID()
and void prepareDuplicate(uint16_t packetID)
to support this. I was reluctant to add further overloads of the publish()
method with a *dup_id
parameter (as in lwmqtt) and opted for this simpler design. Most users of this library do not care for this functionality and ones that do, have now a way to do it. Let me know what you think. Here is the documentation from the Readme:
Obtain the last used packet ID and prepare the publication of a duplicate message using the specified packet ID:
uint16_t lastPacketID();
void prepareDuplicate(uint16_t packetID);
- These functions may be used to implement a retry logic for failed publications of QoS1 and QoS2 messages.
- The
lastPacketID()
function can be used after callingpublish()
to obtain the used packet ID. - The
prepareDuplicate()
function may be called beforepublish()
to temporarily change the next used packet ID and flag the message as a duplicate.
from arduino-mqtt.
Hi @256dpi the duplicate logic seems to be working fine. Thanks.
One thing I noticed is the following, if I use dropOverflow(true)
when a very big message arrives, mqtt disconnects. Is that normal? Shouldn't it just ignore the package without disconnecting?
from arduino-mqtt.
Thanks for the feedback! No, the client should not disconnect. On such an error loop()
should return false
and the error can be obtained using lastError()
. What does it say?
from arduino-mqtt.
LWMQTT_BUFFER_TOO_SHORT
from arduino-mqtt.
Hi @256dpi I think I have a "kind of bug" in the way the duplicate is handled.
If you use the new function prepareDuplicate(duplicateID)
it will publish as duplicate OK. But internally, it will not reset the class variable nextDupPacketID
after publishing, thus every packet published afterwars will be marked as duplicate with the same ID unless you call prepareDuplicate(0)
. Maybe it should be a good idea to reset nextDupPacketID
after publish (successful or not)?
from arduino-mqtt.
Yes that makes sense. I'll see if I find time to fix that this week.
from arduino-mqtt.
Any news about it?
from arduino-mqtt.
Related Issues (20)
- Issue with latest lwmqtt and the separation of the header and the payload HOT 4
- MQTT reconnection when not disconnected. ESP8266 HOT 6
- Unreliable behaviour with reconnections HOT 3
- MQTT HOT 1
- Websockets support HOT 3
- MQTT SSL connection issue with QoS1 and QoS2 messages HOT 1
- DCU: cannot connect to local MQTT broker HOT 1
- This library uses some posix functions that are not provided for Uno R4 HOT 3
- Subscribe query HOT 1
- Release version `v2.5.1` different of master version HOT 1
- 0
- Error connect MQTT SSL/TLS with module CBU use platform libretiny
- RP2040 seems to work fine HOT 2
- payload length / reconnect HOT 1
- Random error in MQTTClient::loop() function HOT 2
- Cosmetics only in MQTTClient.h / MQTTClient(...)
- Wrong version in README.md?
- ESP32 PSRAM for MQTT buffer?
- if available bytes on the network is available, close connection. HOT 1
- MQTT5 HOT 1
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 arduino-mqtt.