About Lost data


I’m trying to learn mqtt and python programing. After some struggle, I’m able to connect cloud with raspberry picow.

In web client page, I can see data came from pico, as in first screen shot.

But, when I refresh the page, or disconnect client somehow, data that already taken is lost and no new data as in second screen shot.

Is it normal?

Hi @aeren

Greetings! We’re thrilled to have you here, showing interest in MQTT and the HiveMQ broker. Welcome to the HiveMQ Community! We’re always happy to see new users.

During the period between the time you refreshed the browser and the moment the second screenshot was taken, the RPi MQTT client did not publish any new messages to the specific topic that the Web Client is subscribed to. This explains the absence of new messages in the list of received messages after you refresh the browser.

I hope this information provides clarity on the matter. If you have any further questions or require additional assistance, please don’t hesitate to reach out. We’re here to help in any way we can.

Dasha from HiveMQ Team

Dear Dasha,

Thanks for the prompt reply. Unfortunutely, that is not the case.

Please pay attantion to topic called “R_pico_w/P_Say”. I count how many times pico publishs with that.

In below example, I published every 30 seecends. When I disconnect after publish number 22, when I reconnect, I cannot see data before publish number 30.

Hi @aeren,

Why you are not seeing messages 23-29 in the received message list? Because the MQTT broker stores messages in a queue only for clients that have a persistent session with the broker. A persistent session is created when the client sets “cleanStart=false” and “sessionExpiry > 0” while connecting to the broker. Additionally, the messages should have a quality of service (QoS) level of 1 or 2.

In your case, the Web Client always creates a clean session, because it is a simple demo client and has limited options. To observe messages queued, you’ll need to use a different MQTT client that provides more connection options.

One client we can suggest is the HiveMQ MQTT CLI command line client, which you can find here: Home - HiveMQ MQTT Client.

If you need guidance on how to create a persistent session with MQTT CLI, please refer to this link: Persistant Session & Queuing Message, Session Expiry - #9 by Daria_H.

For more in-depth information about persistent sessions, you can check out this article: Understanding Persistent Sessions and Clean Sessions – MQTT Essentials: Part 7.

I hope this information proves helpful to you. If you have any further questions or require additional assistance, please don’t hesitate to ask.

Best regards,
Dasha from the HiveMQ Team

Hımm… Ok that explains a lot. I will work on it.