What is the clientID needed for?

15.1k views Asked by At

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?

1

There are 1 answers

5
Dominik Obermaier On BEST ANSWER

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.