MQTT reconnection | Telit Cinterion IoT Developer Community
February 23, 2021 - 10:59am, 1729 views
Good Morning.
Cinterion
EHS6
REVISION 03.001
A-REVISION 00.000.51
I am using the MQTT library "MqttClient2016.jar" taken from: https://iot-developer.thalesgroup.com/comment/9842#comment-9842
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!
Hello,
Is there any evidence od reconnection attempt in the log? Any errors? Is the module registered to the network? The software you refer to is a demo so it may not be 100% reliable. Please also try to send some message from the module?
Regards,
Bartłomiej
Hello.
I can't know if it returns any error. Since I was never able to run programs directly in eclipse. I have to pass them to the module and run them from there to test. Because of this, the "system.out.print" of the exceptions, which are in this library, I cannot see.
I have done the reconnection on my own. I have turned off the server for a few minutes and turned it back on. I have removed the sims from the module for a few minutes and I have put it back. In both cases it has reconnected well and without problems.
As it has worked for me I will leave it like that, since not being able to execute directly from eclipse, it is difficult for me to follow the trace of an error, to get the problem it gave (if there was one).
Thank you very much for your answer. and thanks for the library that is very helpful.
Hello,
Good that you have found a solution that works for you.
There are also a source files attached as I can see. So you'd probably have to use them and enable some debug inside to see more what is happening.
Best regards,
Bartłomiej