MQTT isn't stable

Hi friends,

I'm having problems to keep a connection from an Arduino to a MQTT server. I'm using the PubSubClient.h library to connect and the Timer.h one to restart the Arduino every 4 hours and so reconnect to server. Even restarting the Arduino, after some time it stops receiving the messages from the MQTT server. It looks that the Arduino lost the connection or some exception stops the process.

Has anyone already got this problem or any similar one when using MQTT?

Thanks,

I have the same problem.

How do you keep status of client connection?

In loop() I'm using a while(client.connected() != 1){ client.connect(); delay(1000); } block to try to avoid mqtt disconnecting and stuff, but still with publishing problems.

Regards,