Fix infinite loop when delivering MQTT messages.