From e2ebddfc543b72cc24f58a47dfd49f22a872e07b Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Fri, 15 Jan 2021 13:54:14 +0000 Subject: [PATCH] Improve logging in obscure cases when a client disconnects. Closes #2017. Thanks to Craig Leres. --- ChangeLog.txt | 1 + src/loop.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index fa5c44b47a..509a2fe47a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -6,6 +6,7 @@ Broker: - Fix websockets listeners with TLS not responding. Closes #2020. - Add notes that libsystemd-dev or similar is needed if building with systemd support. Closes #2019. +- Improve logging in obscure cases when a client disconnects. Closes #2017. Apps: - Allow command line arguments to override config file options in diff --git a/src/loop.c b/src/loop.c index aa1367d8e4..ba146c25a1 100644 --- a/src/loop.c +++ b/src/loop.c @@ -353,8 +353,11 @@ void do_disconnect(struct mosquitto *context, int reason) case MOSQ_ERR_ADMINISTRATIVE_ACTION: log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s been disconnected by administrative action.", id); break; + case MOSQ_ERR_ERRNO: + log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected: %s.", id, strerror(errno)); + break; default: - log__printf(NULL, MOSQ_LOG_NOTICE, "Bad socket read/write on client %s, disconnecting.", id); + log__printf(NULL, MOSQ_LOG_NOTICE, "Bad socket read/write on client %s: %s.", id, mosquitto_strerror(reason)); break; } }else{