From 611ad222bb1d45501d3055928d036446a3537d44 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 15 Mar 2018 11:13:17 +0000 Subject: [PATCH] Don't keep trying to connect in sub client if CONNACK negative. --- ChangeLog.txt | 2 ++ client/sub_client.c | 1 + 2 files changed, 3 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 3cb79d0d..5bd29dde 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -101,6 +101,8 @@ Clients: - Connections now default to using MQTT v3.1.1. - Default to using port 8883 when using TLS. - Correctly handle empty files with "mosquitto_pub -l". Closes #676. +- mosquitto_sub doesn't continue to keep connecting if CONNACK tells it the + connection was refused. Build: - Add WITH_STRIP option (defaulting to "no") that when set to "yes" will strip diff --git a/client/sub_client.c b/client/sub_client.c index 1fb6fb75..280dca56 100644 --- a/client/sub_client.c +++ b/client/sub_client.c @@ -367,6 +367,7 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result) if(result && !cfg->quiet){ fprintf(stderr, "%s\n", mosquitto_connack_string(result)); } + mosquitto_disconnect(mosq); } }