You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use a modified version of the sample code for Arduino (I'm using an ESP01 with arduino's framework) however, if I try to retain the messages as I did below in msg_online() and in the last will, they are published as not retained 99% of time. Every once in while they are set as retained, but it a very very rare case. Would you know where the problem in my code is or suggest some solutions?
This is my code below (I only cleared my Wifi and personal broker fields for privacy reasons, but I have the problem both with my broker and with hiveMQ's public broker, so I left only hivemq's broker field):
I'm too lazy to dig in your code and find what you are doing for you.
If you believe either the client or the library does not work properly then write the smallest possible example where this can be reproduced, post how you call the client or the library, what you get back, and confirm that with a network capture showing the flag is indeed not as it should.
In the library struct Message, retained is bool, whence I set it correctly setting it to true. The publish function I call, in the library is declared as:
template<class Network, class Timer, int MAX_MQTT_PACKET_SIZE, int b>
int MQTT::Client<Network, Timer, MAX_MQTT_PACKET_SIZE, b>::publish(const char* topicName, Message& message)
{
return publish(topicName, message.payload, message.payloadlen, message.qos, message.retained);
}
This HiveMQ public client shows if the message is retained, as you can see there is a previously published online that is retained, but the new one not. As I said, sometimes it publishes it retained but 99% of the times not... I guess it's a problem of the library, because if with the same code sometimes the message is retained but many times not, the code should be right I guess....
Hello there,
I'm trying to use a modified version of the sample code for Arduino (I'm using an ESP01 with arduino's framework) however, if I try to retain the messages as I did below in msg_online() and in the last will, they are published as not retained 99% of time. Every once in while they are set as retained, but it a very very rare case. Would you know where the problem in my code is or suggest some solutions?
This is my code below (I only cleared my Wifi and personal broker fields for privacy reasons, but I have the problem both with my broker and with hiveMQ's public broker, so I left only hivemq's broker field):
Kind regards,
Vur
The text was updated successfully, but these errors were encountered: