From 2233be8e7a24ce9583de524a07f874aed225ea1c Mon Sep 17 00:00:00 2001 From: ryzendigo Date: Tue, 17 Mar 2026 06:56:19 +0800 Subject: [PATCH] fix: prevent MQTT from setting connected state on failed connections When the MQTT broker rejects a connection (bad credentials, not authorized, etc.), _on_connect still unconditionally sets connected=True, subscribes to topics, and calls _set_initial_topics(). This causes publish() to attempt sending messages to a broker that rejected the connection. Add an early return after logging the connection error so the client correctly remains in a disconnected state. --- frigate/comms/mqtt.py | 1 + 1 file changed, 1 insertion(+) diff --git a/frigate/comms/mqtt.py b/frigate/comms/mqtt.py index 9279b4388..8388d79dd 100644 --- a/frigate/comms/mqtt.py +++ b/frigate/comms/mqtt.py @@ -199,6 +199,7 @@ class MqttClient(Communicator): "Unable to connect to MQTT server: Connection refused. Error code: " + reason_code.getName() ) + return self.connected = True logger.debug("MQTT connected")