Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mqtt: is it necessary to unsubscribe?

Tags:

mqtt

If a client is disconnecting, is it necessary to unsubscribe beforehand?

I originally thought it was, but then if a client disconnects unexpectedly, you cannot unsubscribe ..

therefore, unsubscribing is pointless unless you are still connected and no longer want to receive messages ..

Is this a correct assumption?

like image 691
pstanton Avatar asked Dec 11 '22 15:12

pstanton


1 Answers

If you have connected with the clean session flag set to 1 then when you disconnect the broker will remove all of your subscriptions and other information.

If clean session was set to 0 when you connected, then your subscriptions are saved at the broker until you unsubscribe (or reconnect with clean session set to 1 at a later point)

like image 89
ralight Avatar answered Mar 27 '23 12:03

ralight