What happens to topic updates when the subscriber is down?

1,343 views
Skip to first unread message

RK

unread,
May 16, 2015, 2:04:43 PM5/16/15
to mq...@googlegroups.com
Hello All:

 I am new to MQTT and the rest of the IoT and other software constructs outside of automotive control systems. I have a fundamental question about the behavior of the broker.

Use case is 
1. A subscriber to a topic goes offline.
2. Publisher of that topic sends an update / new PUBLISH message
Question
Does the MQTT broker store this message until the subscriber is back online? Or it simply maintains a list of currently active subscribers and delivers the message only to them?

Background
I intend to use MQTT Broker on a Raspberry Pi and the clients could be controlled units like fans / lights / door locks etc.,
My MQTT clients will be on an MCU running FreeRTOS connected to ESP8266 - Does anybody have a recommendation / suggestion on a embedded C client implementation?

Nicholas O'Leary

unread,
May 16, 2015, 3:29:16 PM5/16/15
to mq...@googlegroups.com
Hi,

if a client connects with the clean session flag set to false (how exactly will depend on what client library you are using), then subscribes, the server will queue up QoS 1 and 2 messages for it whilst it is offline.

This blog post does a good job of explaining the details: http://www.hivemq.com/mqtt-essentials-part-7-persistent-session-queuing-messages/

Nick


--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at http://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Shawn McAllister

unread,
May 16, 2015, 8:59:26 PM5/16/15
to mq...@googlegroups.com

Hi Ravi – see inline.

 

Shawn

 

From: mq...@googlegroups.com [mailto:mq...@googlegroups.com] On Behalf Of RK
Sent: May-16-15 2:05 PM
To: mq...@googlegroups.com
Subject: [mqtt] What happens to topic updates when the subscriber is down?

 

Hello All:

 

 I am new to MQTT and the rest of the IoT and other software constructs outside of automotive control systems. I have a fundamental question about the behavior of the broker.

 

Use case is 

1. A subscriber to a topic goes offline.

2. Publisher of that topic sends an update / new PUBLISH message

Question

Does the MQTT broker store this message until the subscriber is back online? Or it simply maintains a list of currently active subscribers and delivers the message only to them?

[SPM] in order to ensure that a message published while a subscriber is offline is stored by the broker so the subscriber can retrieve the message when the subscriber comes back online:

-          The publisher must publish its messages with a QoS of 1 or 2 – not 0.  (each message published is given a QoS)

-          The subscriber must issue its Subscribe for the topic with a QoS of 1 or 2- not zero (each subscription has a QoS)

-          Subscribers must connect to the broker with the Clean Flag = 0  - so that all its state is maintained by the broker (clean = 1 deletes all previous state on the broker)

 

 

Background

I intend to use MQTT Broker on a Raspberry Pi and the clients could be controlled units like fans / lights / door locks etc.,

My MQTT clients will be on an MCU running FreeRTOS connected to ESP8266 - Does anybody have a recommendation / suggestion on a embedded C client implementation?

[SPM] we’ve used the C API at http://wiki.eclipse.org/Paho quite successfully.

 

 

 

 

RK

unread,
May 17, 2015, 10:58:21 PM5/17/15
to mq...@googlegroups.com
Hello Nick and Shawn,

Thanks for the answers - it was cleared up a quite a few things for me.

Regards,
Ravi
Reply all
Reply to author
Forward
0 new messages