Since specifying the clienID
is only a feature in the class MqttAndroidClient
, and can not be specified when using classes IMqttClient
and IMqttAsynchClient
.
what is the real purpose of connecting a client with a unique ID
?
Since specifying the clienID
is only a feature in the class MqttAndroidClient
, and can not be specified when using classes IMqttClient
and IMqttAsynchClient
.
what is the real purpose of connecting a client with a unique ID
?
Every MQTT Connection needs a unique client ID. With this unique client ID the broker can recognize when a client reconnects and can close an old potentially half-open TCP connection for the client. Also, the MQTT broker can hold a persistent session for MQTT clients if they desire to do so (cleanSession=false on CONNECT). If you disconnect and reconnect with the same client ID, you will receive all messages for your subscriptions you may have missed and the broker knows your old subscriptions for that client ID.
© 2022 - 2024 — McMap. All rights reserved.