The service was seen staying disconnected from the broker. The old reconnect loop polled IsConnected every 5 s (hardcoded), never logged disconnects, and used MQTTnet's default 100 s connect timeout. The docs also pointed to WithReconnectDelay, which only exists on ManagedMqttClient.
What
Spec: new SPEC.md §5.2 Connection & reconnect, plus matching PLAN.md design and verification steps and IMPLEMENTATION.md increment 6.6.
Each disconnect is logged with its reason (e.g. SessionTakenOver, KeepAliveTimeout) and triggers a reconnect loop with capped backoff that resets on success.
Only the loop calls ConnectAsync, so connects never run concurrently.
An idle safety check covers missed disconnect events.
Queued publishes drain immediately after a reconnect.
Note
One likely cause of the original incident is a ClientId collision: a dev instance and the deployed instance both using frame-processor against the same broker would keep kicking each other off. The new disconnect log will show SessionTakenOver if so. If it does, use a distinct Mqtt__ClientId locally.
Testing
dotnet build and dotnet test pass (174 tests).
Startup validation still fails fast on bad Mqtt options.
Not yet run live (no Docker or broker was available): PLAN.md verification items 7, 7a and 7b (broker restart, half-open link, ClientId collision). IMPLEMENTATION.md 6.6 stays unchecked until they pass.
## Why
The service was seen staying disconnected from the broker. The old reconnect loop polled `IsConnected` every 5 s (hardcoded), never logged disconnects, and used MQTTnet's default 100 s connect timeout. The docs also pointed to `WithReconnectDelay`, which only exists on `ManagedMqttClient`.
## What
- **Spec:** new SPEC.md §5.2 *Connection & reconnect*, plus matching PLAN.md design and verification steps and IMPLEMENTATION.md increment 6.6.
- **Config:** `Mqtt.ReconnectBackoffSeconds` (default `[1, 2, 5, 15, 30]`), `KeepAliveSeconds` (15) and `ConnectTimeoutSeconds` (10).
- **MqttPublisher:**
- Each disconnect is logged with its reason (e.g. `SessionTakenOver`, `KeepAliveTimeout`) and triggers a reconnect loop with capped backoff that resets on success.
- Only the loop calls `ConnectAsync`, so connects never run concurrently.
- An idle safety check covers missed disconnect events.
- Queued publishes drain immediately after a reconnect.
## Note
One likely cause of the original incident is a **ClientId collision**: a dev instance and the deployed instance both using `frame-processor` against the same broker would keep kicking each other off. The new disconnect log will show `SessionTakenOver` if so. If it does, use a distinct `Mqtt__ClientId` locally.
## Testing
- `dotnet build` and `dotnet test` pass (174 tests).
- Startup validation still fails fast on bad Mqtt options.
- **Not yet run live** (no Docker or broker was available): PLAN.md verification items 7, 7a and 7b (broker restart, half-open link, ClientId collision). IMPLEMENTATION.md 6.6 stays unchecked until they pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Add SPEC.md §5.2 describing reconnect requirements (backoff, keep-alive
detection, disconnect logging, unique ClientId), the new Mqtt config
keys, the matching PLAN.md design and verification steps, and
IMPLEMENTATION.md increment 6.6. Also drop the stale WithReconnectDelay
reference, which only exists on ManagedMqttClient.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Replace the hardcoded 5 s IsConnected poll with a loop driven by
DisconnectedAsync (plus an idle safety check), retrying on the
ReconnectBackoffSeconds schedule. Disconnects are now logged with their
reason, and keep-alive and connect timeout come from config so dead
links are detected and connect attempts can't block for 100 s.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Why
The service was seen staying disconnected from the broker. The old reconnect loop polled
IsConnectedevery 5 s (hardcoded), never logged disconnects, and used MQTTnet's default 100 s connect timeout. The docs also pointed toWithReconnectDelay, which only exists onManagedMqttClient.What
Mqtt.ReconnectBackoffSeconds(default[1, 2, 5, 15, 30]),KeepAliveSeconds(15) andConnectTimeoutSeconds(10).SessionTakenOver,KeepAliveTimeout) and triggers a reconnect loop with capped backoff that resets on success.ConnectAsync, so connects never run concurrently.Note
One likely cause of the original incident is a ClientId collision: a dev instance and the deployed instance both using
frame-processoragainst the same broker would keep kicking each other off. The new disconnect log will showSessionTakenOverif so. If it does, use a distinctMqtt__ClientIdlocally.Testing
dotnet buildanddotnet testpass (174 tests).🤖 Generated with Claude Code