I’m having some issues losing data even with persistent set and clean flag false.
When my subscriber lost connection, when it gets back, it doesn’t catchup with data, but start just from the new messages.
I do have persistent storage on my server, but on client it’s just memory. Do I need to have in both client and server in order to guarantee persistent data?
When using cleanSession=false you should see the behaviour you are expecting
See this blogpost
If you want to quickly verify that your client implementation is correct, you can test against the public HiveMQ broker at tcp://broker.hivemq.com:1883
Yes, I saw that post, my concern was because of this part:
Persistent session on the client side
Similar to the broker, each MQTT client must also store a persistent session. When a client requests the server to hold session data, the client is responsible for storing the following information:
All messages in a QoS 1 or 2 flow, that are not yet confirmed by the broker.
All QoS 2 messages received from the broker that are not yet completely acknowledged.
And I use MemoryPersistence on client, which means if client restart, it loses the session. But the broker do have in file persistence. In this case, would the persistency still work?
Please excuse my delayed response.
HiveMQ will persist a clients session regardless of the clients persistence configuration.
This means that all subscriptions will be persisted on the broker and messages arrived on topics that match the clients subscriptions will be held in an offline message queue and then delivered to the client upon re-connection.
In case you are looking for specific implementation details regarding the Paho Golang or mosquitto broker implementation, please refer to the corresponding support or community.
Thank you and kind regards,
Florian from The HiveMQ Team.