Add explicit error logging for MQTT publish attempts before/after connection availability - #169
Conversation
Architectural Code Review — PR #169Linked IssueIssue #120 — "add logging pre-connection"
SummaryReplaces the silent Issue → Implementation Gap Analysis
No gaps. The PR fully satisfies Issue #120. CONTRIBUTING.md Compliance
Architecture Assessment✅ Triple-check is defense-in-depth. The three conditions catch distinct failure modes:
✅ Fail-fast with early return. Previously, if ✅ Existing logging preserved. The ✅ Correctly uses Observations (non-blocking)
Verdict: ✅ APPROVENo blocking issues. Clean, minimal change that converts a silent failure (or potential crash) into a diagnosable error log. Fully satisfies Issue #120. |
Publish calls were silently accepted when the MQTT session was not actually open, making pre-connection and post-disconnect failures hard to diagnose. This change adds an explicit connection-state gate in the publish path and emits a clear error when a publish is attempted while disconnected.
Publish-path connection guard
ArenaMqttClient.Publish(...)to fail fast unless the broker session is open.client == null!mqttClientConnected!client.IsConnectedOperational visibility for dropped publishes
Behavior when connected remains unchanged