diff options
author | V.Krishn <vkrishn4@gmail.com> | 2019-12-04 12:26:49 +0530 |
---|---|---|
committer | V.Krishn <vkrishn4@gmail.com> | 2019-12-04 12:26:49 +0530 |
commit | 66dbf24f8a5dc90e896ebaa45837af52715038a6 (patch) | |
tree | 5b5f9772dd1839ea98408a6846ca0bdbd30538fa | |
parent | 756676b552896cfa016dc94818b85e6ff8440c27 (diff) | |
download | mqtt-dirpub-66dbf24f8a5dc90e896ebaa45837af52715038a6.tar.bz2 |
update to mosquitto-v1.6.4
-rw-r--r-- | client_shared.c | 12 | ||||
-rw-r--r-- | sub_client.c | 12 |
2 files changed, 13 insertions, 11 deletions
diff --git a/client_shared.c b/client_shared.c index 8923f40..7c6b4e7 100644 --- a/client_shared.c +++ b/client_shared.c @@ -438,7 +438,7 @@ int cfg_add_topic(struct mosq_config *cfg, int type, char *topic, const char *ar cfg->topic_count++; cfg->topics = realloc(cfg->topics, cfg->topic_count*sizeof(char *)); if(!cfg->topics){ - fprintf(stderr, "Error: Out of memory.\n"); + err_printf(cfg, "Error: Out of memory.\n"); return 1; } cfg->topics[cfg->topic_count-1] = strdup(topic); @@ -1456,11 +1456,11 @@ static int mosquitto__parse_socks_url(struct mosq_config *cfg, char *url) return 0; cleanup: - if(username_or_host) free(username_or_host); - if(username) free(username); - if(password) free(password); - if(host) free(host); - if(port) free(port); + free(username_or_host); + free(username); + free(password); + free(host); + free(port); return 1; } #endif diff --git a/sub_client.c b/sub_client.c index ff69931..33efcb3 100644 --- a/sub_client.c +++ b/sub_client.c @@ -133,9 +133,13 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flag }else{ if(result){ if(cfg.protocol_version == MQTT_PROTOCOL_V5){ - err_printf(&cfg, "%s\n", mosquitto_reason_string(result)); + if(result == MQTT_RC_UNSUPPORTED_PROTOCOL_VERSION){ + err_printf(&cfg, "Connection error: %s. Try connecting to an MQTT v5 broker, or use MQTT v3.x mode.\n", mosquitto_reason_string(result)); + }else{ + err_printf(&cfg, "Connection error: %s\n", mosquitto_reason_string(result)); + } }else{ - err_printf(&cfg, "%s\n", mosquitto_connack_string(result)); + err_printf(&cfg, "Connection error: %s\n", mosquitto_connack_string(result)); } } mosquitto_disconnect_v5(mosq, 0, cfg.disconnect_props); @@ -293,8 +297,6 @@ int main(int argc, char *argv[]) #ifndef WIN32 struct sigaction sigact; #endif - - memset(&cfg, 0, sizeof(struct mosq_config)); mosquitto_lib_init(); @@ -371,7 +373,7 @@ int main(int argc, char *argv[]) } client_config_cleanup(&cfg); if(rc){ - fprintf(stderr, "Error: %s\n", mosquitto_strerror(rc)); + err_printf(&cfg, "Error: %s\n", mosquitto_strerror(rc)); } return rc; |