notification/mqtt: ensure network communication and check error
This commit is contained in:
parent
a6c042a4f7
commit
c70d6cd18f
1 changed files with 3 additions and 0 deletions
|
@ -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()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue