rmaik
rmaik

Reputation: 1086

What is the clientID needed for?

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?

Upvotes: 10

Views: 17574

Answers (1)

Dominik Obermaier
Dominik Obermaier

Reputation: 5770

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.

Upvotes: 19

Related Questions