What is the clientID needed for?
Asked Answered
A

1

9

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?

Aphonia answered 27/11, 2014 at 15:38 Comment(0)
C
17

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.

Castano answered 27/11, 2014 at 17:29 Comment(5)
Thank you a lt for the informatio. but when i try to use IMqqttClient class r IMqtttAsynchClient class, there is no way provded to specify he clientID or the IP. i have cecked the internet for any example for the aforementioned classes to see how one can specify ID and IP but there is no such examples. any guidance or advise?Aphonia
They are interfaces and cannot be instantiated.Heraclea
@AlessandroDaRugna maybe this could be a questin for you :) #27174771Aphonia
@Dominik Obermaier maybe you can answer his question as well #27397917Aphonia
specs for both 3.1 and 5.0 say that the server will handle this for you if client_id is empty so if we're talking about implementation, the client_id can be left empty and unassigned.Baddie

© 2022 - 2024 — McMap. All rights reserved.