The cloud MQTT module implements an internal state machine to manage the connection and reconnection logic.