hello, i am new in mqtt, i am in a middle of developing a android project that required a automatic reconnect to mqtt broker, and when reconnect, i want to automatically re-subcribe the topic.
i want to ask, what is the best practice to reconnect into a broker but when reconnect its also subscribe into topic
Greetings and welcome to the HiveMQ Community Forum! We’re delighted to see your interest in MQTT and HiveMQ.
May we kindly inquire whether you are currently using the HiveMQ Java client library? If you are, we have provided examples on how to implement reconnection in our Git repository. You can access these examples here.
Moreover, if your aim is to have clients retain all subscribed topics after a reconnection, we recommend utilizing persistent sessions. Our blog post on persistent sessions provides valuable insights, and you can access it here. For implementation with the Mqtt 5 client, you can use
cleanStart(false), and for Mqtt 3 client, you can use
Feel free to explore these resources, and if you have any further questions or require assistance, feel free to respond here.
Sheetal from the HiveMQ Team
yes, i am using HiveMq Java client library , ok thanks for the info @SShet