I have an use case which requires persisting the MQTT messages in Broker whenever a subscriber goes offline. When the subscriber reconnects all the messages published when it was offline should be delivered.
To achieve this I am using the Node Red MQTT Out and In nodes for publish subscribe. My Node Red Version is 0.17.5 . I am using Mosquitto Broker Version 1.4.9.
For persisting messages,
At the subscriber side:
I have provided valid entries for Topic , Qos(1) ,Server, Port ,Keep Alive(60s),Client Id.Following entries are kept unchecked
1.Use Clean Session 2. Enable secure SSL/TLS Connection.
The option 'Use Legacy MQTT 3.1' support is kept checked.
At the Publisher side:
Similar settings are replicated. Client Id is automatically set to the client id of subscriber .Retain option is not chosen.
I triggered timestamp values at publisher side by keeping subscriber connected to broker in a separate flow .The subscriber was able to receive messages. Then I disabled the flow with subscriber. Did a redeploy. Triggered the time stamp messages again from publisher side. Reenabled the flow with subscriber and redeployed. The subscriber was not able to retrieve the messages published when it was disabled.
I was able to reproduce persistence using Mosquitto Pub and Sub clients with the following command line options but I am not able to achieve the same using Node Red. I could achieve the message retrieval/subscription in Node Red only when the subscriber is online at the time of publishing.
mosquitto_sub -h 127.0.0.1 --disable-clean-session -t demoone -q 1 -i demooneclient
mosquitto_pub -h 127.0.0.1 -t demoone -m "Hello" -q 1.