Skip to content

MQTT connection not automatically reconnecting after unexpected AWS hangup #85

@eman

Description

@eman

Summary

After an unexpected MQTT hangup (AWS_ERROR_MQTT_UNEXPECTED_HANGUP), the library does not automatically reconnect. The CONNECTION_INTERRUPTED event is fired, but CONNECTION_RESUMED never fires. The connection remains dead until the application is manually restarted.

Steps to Reproduce

  1. Run ha_nwp500 integration for several days
  2. Wait for an unexpected connection hangup to occur (appears to happen daily around 3:43 AM)
  3. Observe logs showing CONNECTION_INTERRUPTED event
  4. No CONNECTION_RESUMED event is emitted
  5. Device sensors become unavailable

Expected Behavior

  • After CONNECTION_INTERRUPTED event, automatic reconnection should attempt to restore the connection
  • CONNECTION_RESUMED event should fire when reconnection succeeds
  • If automatic reconnection fails, it should retry with exponential backoff

Environment

  • nwp500-python: (eval branch)
  • AWS IoT Core MQTT endpoint: a1t30mldyslmuq-ats.iot.us-east-1.amazonaws.com

Error Pattern

Connection interrupted (no reconnection follows):

2026-05-12 03:43:21.926 WARNING [nwp500.mqtt.reconnection] Connection interrupted: AWS_ERROR_MQTT_UNEXPECTED_HANGUP: The connection was closed unexpectedly.

The connection remains down until manual restart.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions