Persistent on both client and server

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?

Many thanks.

Hey Caevv,

can you please describe what you are seeing in a little bit more detail.

  • What Broker / Client implementation are you using?
  • Which QoS level are the messages being sent in?
  • Which MQTT version are you using?
  • What is the exact behaviour you are seeing?
  • What is the expected behaviour you want to see?
  • What Broker / Client implementation are you using?
    Broker: Mosquitto
    Client: eclipse/paho.mqtt.golang

  • Which QoS level are the messages being sent in?
    2

  • Which MQTT version are you using?
    Mosquitto

  • What is the exact behaviour you are seeing?

  1. Subscriber lose connection
  2. Messages still being produced
  3. Subscriber connects, but start from new messages only.
  • What is the expected behaviour you want to see?
  1. Subscriber lose connection
  2. Messages still being produced
  3. Subscriber connects, start reading messages from the point is lost connection, until it catchup and then move to live data.

Many thanks.

Hey there. Thank you for you response.

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

Thanks.

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?

@caevv

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.