Gemalto is now part of the Thales Group, find out more.

You are here

MQTT reconnection | Thales IoT Developer Community

February 23, 2021 - 10:59am, 1681 views

Good Morning.

A-REVISION 00.000.51

I am using the MQTT library "MqttClient2016.jar" taken from:

The connection works perfectly for me and receives the messages without any problem.

I have the problem if the internet connection is lost, or if the server is restarted. It does not reconnect. I configure the options with the following command:

  connOpts.setAutomaticReconnect (true);

as indicated by the main class in the example.

I use the MyMqttCallback interface that also appears in the main class.

When the connection is lost, I get the message "[MyMqttCallback]: Connection lost because"

So it detects the loss, but then it does nothing more, and I keep sending messages and it does not receive them again once the connection is lost.

Should I do anything else to make the reconnection work?
Or should I do this reconnection on my own?

Thank you!