Fix address and port missing from disconnect messages

This commit is contained in:
Roger A. Light
2026-02-02 23:50:42 +00:00
parent a71685e8ff
commit 750c0f44d8
2 changed files with 29 additions and 27 deletions
+2
View File
@@ -2,10 +2,12 @@
==================
# Broker
- Fix PUID/PGID checking for docker
- Add MOSQUITTO_UNSAFE_ALLOW_SYMLINKS environment variable to allow the
restrictions on reading files through symlinks to be lifted in safe
environments like kubernetes. Closes #3461.
- Fix inconsistent disconnect log message format, and add address:port.
2.1.0 - 2026-01-29
+27 -27
View File
@@ -318,89 +318,89 @@ void do_disconnect(struct mosquitto *context, int reason)
case MOSQ_ERR_SUCCESS:
break;
case MOSQ_ERR_MALFORMED_PACKET:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected due to malformed packet.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected due to malformed packet.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_PROTOCOL:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected due to protocol error.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected due to protocol error.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_CONN_LOST:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s closed its connection.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] closed its connection.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_AUTH:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected, not authorised.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected, not authorised.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_KEEPALIVE:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s has exceeded timeout, disconnecting.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] has exceeded timeout, disconnecting.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_OVERSIZE_PACKET:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected due to oversize packet.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected due to oversize packet.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_PAYLOAD_SIZE:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected due to oversize payload.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected due to oversize payload.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_NOMEM:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected due to out of memory.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected due to out of memory.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_NOT_SUPPORTED:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected due to using not allowed feature (QoS too high, retain not supported, or bad AUTH method).", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected due to using not allowed feature (QoS too high, retain not supported, or bad AUTH method).", id, context->address, context->remote_port);
break;
case MOSQ_ERR_ADMINISTRATIVE_ACTION:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s been disconnected by administrative action.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] been disconnected by administrative action.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_ERRNO:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected: %s.", id, strerror(errno));
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected: %s.", id, context->address, context->remote_port, strerror(errno));
break;
case MOSQ_ERR_RECEIVE_MAXIMUM_EXCEEDED:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected due to exceeding the receive maximum.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected due to exceeding the receive maximum.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_IMPLEMENTATION_SPECIFIC:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected, implementation specific error.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected, implementation specific error.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_CLIENT_IDENTIFIER_NOT_VALID:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected, client identifier not valid.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected, client identifier not valid.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_BAD_USERNAME_OR_PASSWORD:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected, bad username or password.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected, bad username or password.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_SERVER_UNAVAILABLE:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected, server unavailable.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected, server unavailable.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_SERVER_BUSY:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected, server busy.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected, server busy.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_BANNED:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected, client banned.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected, client banned.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_BAD_AUTHENTICATION_METHOD:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected, bad authentication method.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected, bad authentication method.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_QUOTA_EXCEEDED:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected, quota exceeded.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected, quota exceeded.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_CONNECTION_RATE_EXCEEDED:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected, connection rate exceeded.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected, connection rate exceeded.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_SESSION_TAKEN_OVER:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected, session taken over.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected, session taken over.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_TOPIC_ALIAS_INVALID:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected, topic alias invalid.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected, topic alias invalid.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_HTTP_BAD_ORIGIN:
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected, non-matching http origin.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected, non-matching http origin.", id, context->address, context->remote_port);
break;
case MOSQ_ERR_PROXY:
/* This was a proxy v2 health check connection, so don't report */
break;
default:
log__printf(NULL, MOSQ_LOG_NOTICE, "Bad socket read/write on client %s: %s", id, mosquitto_strerror(reason));
log__printf(NULL, MOSQ_LOG_NOTICE, "Bad socket read/write on client %s [%s:%d]: %s", id, context->address, context->remote_port, mosquitto_strerror(reason));
break;
}
}else{
if(reason == MOSQ_ERR_ADMINISTRATIVE_ACTION){
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s been disconnected by administrative action.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] been disconnected by administrative action.", id, context->address, context->remote_port);
}else{
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s disconnected.", id);
log__printf(NULL, MOSQ_LOG_NOTICE, "Client %s [%s:%d] disconnected.", id, context->address, context->remote_port);
}
}
}