diff options
author | Bjørn Mork <bjorn@mork.no> | 2019-05-26 21:22:22 +0200 |
---|---|---|
committer | Bjørn Mork <bjorn@mork.no> | 2019-05-26 21:22:22 +0200 |
commit | d601535b690084f62d497e7d6e4d1c3326611a4f (patch) | |
tree | 0094a37523572bc9514c8ef51429b686d84d0c7f | |
parent | 7b0086efb85c19a1bbb057ff6a738a58a94f0672 (diff) |
attempt to reconnect to broker on errors
Signed-off-by: Bjørn Mork <bjorn@mork.no>
-rw-r--r-- | obinsectd.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/obinsectd.c b/obinsectd.c index 73103a2..4bb6661 100644 --- a/obinsectd.c +++ b/obinsectd.c @@ -1227,7 +1227,10 @@ static int publish(struct mosquitto *mosq, json_object *pubdata) continue; pub = json_object_to_json_string_ext(val, JSON_C_TO_STRING_PLAIN); publen = strlen(pub); - mosquitto_publish(mosq, &mid, t, publen, pub, 0, false); + if (mosquitto_publish(mosq, &mid, t, publen, pub, 0, false)) { + debug("mqtt broker went away -reconnecting\n"); + mosquitto_reconnect(mosq); + } } return 0; |