Monday, October 09, 2017

Handling MQTT broker re-connections

Any client that connects to an MQTT broker needs the ability to handle a connection failure.

The popular Eclipse Paho library now has support for reconnects as described here -
Sample client code available here -

If you want to understand how Paho implements reconnect, then have a look at this source file -

Alternatively, we can use the Spring Integration Framework that encapsulates the Paho library and provides options to configure connection retry logic.