Retained message on load session for client re-connection

76 views
Skip to first unread message

Paolo Patierno

unread,
Sep 8, 2016, 4:49:09 AM9/8/16
to MQTT
Hi all,

I have a doubt on the MQTT 3.1.1 spec ... or at least it's not clear to me.

It's clear that after a SUBSCRIBE message for a "topic", if there is a retained message for that "topic" it is sent to the client as last known message.

Now, imagine that a client connect with clean-session 0 and subscribes to some topics. It starts to send SUBSCRIBE messages so it receive retained messages if present.
The client disconnect.
The client reconnect with clean-session 0 and the previous session is loader by the broker. It means that the client is already subscribed to "topic" and it doesn't need to send SUBSCRIBE. In this scenario, does it receive the retained message for "topic" ?

I'm a bit in doubt because the re-subscription isn't executed with a "real" SUBSCRIBE message but just from a re-loading session by the broker.

Thanks,
Paolo.

Roger Light

unread,
Sep 8, 2016, 4:50:49 AM9/8/16
to MQTT
Hi Paolo,

My reading is that retained messages get sent each time a client sends
a SUBSCRIBE message and only then. In your example if the client
doesn't send a SUBSCRIBE message when it reconnects, it won't receive
any retained messages.

Cheers,

Roger
> --
> 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 https://groups.google.com/group/mqtt.
> For more options, visit https://groups.google.com/d/optout.

Paolo Patierno

unread,
Sep 8, 2016, 4:55:41 AM9/8/16
to MQTT
Hi Roger,

it seems the same for me. I agree with you but the spec isn't so clear on that.

Thanks,
Paolo.

Andy Stanford-Clark

unread,
Sep 8, 2016, 11:54:29 AM9/8/16
to mq...@googlegroups.com
yes, that's how it's meant to be
Andy
Reply all
Reply to author
Forward
0 new messages