Manish Kumar
Manish Kumar

Reputation: 10492

Use paho to get previous message and offline message

I am using paho javascript client. I can only see that it provide the way of just receiving & sending message. What if i want something like getting previous conversation, offline message. How can I do that from javascript using paho?

Upvotes: 0

Views: 600

Answers (1)

hardillb
hardillb

Reputation: 59628

Assuming that the broker you are using supports it (most do), MQTT supports persistent sessions.

This means that if a client subscribes to a topic at QOS 1 or 2 then disconnects, when it reconnects (with the same client id) and resubscribes to those topics then any missed messages on that topic will be delivered.

The following blog post has more details http://www.hivemq.com/blog/mqtt-essentials-part-7-persistent-session-queuing-messages

The other option is a retained message on a topic, this is a single message that will be delivered at the point a client subscribes to a topic, before any other messages on that topic. This message will be delivered every time a client reconnects and Subscribers to the topic until it is cleared (by publishing a message with a null payload)

There is no mechanism to specifically request old messages on a topic, you would need to implement any such behaviour yourself.

Upvotes: 1

Related Questions