diff --git a/ChangeLog.txt b/ChangeLog.txt index 4cbce699..5e45c6dd 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,4 @@ -2.0.23 - 2026-01-14 +2.0.23 - 2026-xx-xx =================== Broker: @@ -13,6 +13,7 @@ Broker: - Fix potential crash on startup if a malicious/corrupt persistence file from mosquitto 1.5 or earlier is loaded. Closes #3439. - Limit auto_id_prefix to 50 characters. Closes #3440. +- Fix max_connections not being honoured on websockets listeners. Closes #3455. Windows: - Installer will not overwrite an existing mosquitto.conf diff --git a/src/websockets.c b/src/websockets.c index 688d3b87..0a8e5d0a 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -170,10 +170,12 @@ static int callback_mqtt( u->mosq = NULL; return -1; } + mosq->listener->client_count++; if(mosq->listener->max_connections > 0 && mosq->listener->client_count > mosq->listener->max_connections){ if(db.config->connection_messages == true){ log__printf(NULL, MOSQ_LOG_NOTICE, "Client connection from %s denied: max_connections exceeded.", mosq->address); } + mosq->listener->client_count--; mosquitto__free(mosq->address); mosquitto__free(mosq); u->mosq = NULL; @@ -194,6 +196,7 @@ static int callback_mqtt( HASH_DELETE(hh_sock, db.contexts_by_sock, mosq); mosq->sock = INVALID_SOCKET; mux__delete(mosq); + mosq->listener->client_count--; } mosq->wsi = NULL; #ifdef WITH_TLS