diff --git a/notification/mqtt b/notification/mqtt index efe4557198a..7ac687a2fe3 100644 --- a/notification/mqtt +++ b/notification/mqtt @@ -119,6 +119,9 @@ def publish(module, topic, payload, server='localhost', port='1883', qos='0', module.fail_json(msg="unable to connect to MQTT broker") mqttc.publish(topic, payload, int(qos), retain) + rc = mqttc.loop() + if rc != 0: + module.fail_json(msg="unable to send to MQTT broker") mqttc.disconnect()