1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

notification/mqtt: ensure network communication and check error

This commit is contained in:
Jan-Piet Mens 2013-05-12 11:22:34 +02:00
parent 2a091a3505
commit 98ddb1ca6b

View file

@ -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") module.fail_json(msg="unable to connect to MQTT broker")
mqttc.publish(topic, payload, int(qos), retain) 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() mqttc.disconnect()