Skip to content

Disconnected from MQTT broker #306

@Ziris85

Description

@Ziris85

Describe the bug
It looks like as of the latest release - 1.6.0 - on my install it's constantly disconnecting from/reconnecting to my MQTT broker:

INFO:BLEGateway:Starting BLE scan
INFO:BLEGateway:Connected to MQTT broker
INFO:BLEGateway:Subscribed to home/+/BTtoMQTT/undecoded
INFO:BLEGateway:Subscribed to home/internal/trackersync
ERROR:BLEGateway:Disconnected from MQTT broker with reason code = Unspecified error
INFO:BLEGateway:Connected to MQTT broker
INFO:BLEGateway:Subscribed to home/+/BTtoMQTT/undecoded
INFO:BLEGateway:Subscribed to home/internal/trackersync
ERROR:BLEGateway:Disconnected from MQTT broker with reason code = Unspecified error
INFO:BLEGateway:Connected to MQTT broker
INFO:BLEGateway:Subscribed to home/+/BTtoMQTT/undecoded
INFO:BLEGateway:Subscribed to home/internal/trackersync
INFO:BLEGateway:publishing device `{...etc...}`
ERROR:BLEGateway:Disconnected from MQTT broker with reason code = Unspecified error
ERROR:BLEGateway:Failed to send message to topic home/TheengsGateway/BTtoMQTT/F26C217EBC97
ERROR:BLEGateway:Failed to send message to topic home/TheengsGateway/BTtoMQTT/E246EA8B72F9
ERROR:BLEGateway:Failed to send message to topic home/TheengsGateway/BTtoMQTT/13E03076B90D
ERROR:BLEGateway:Failed to send message to topic home/TheengsGateway/BTtoMQTT/D14D2394CAE5
INFO:BLEGateway:Connected to MQTT broker
INFO:BLEGateway:Subscribed to home/+/BTtoMQTT/undecoded
INFO:BLEGateway:Subscribed to home/internal/trackersync

If I swap to the 1.5.0 version, I don't see this same behavior and the connection is steady. It'll occasionally successfully publish messages in the second or two it's connected.

To Reproduce
Steps to reproduce the behavior:

  1. Install v1.6.0
  2. Run: TheengsGateway -H <mqtt-host> -P 8883 -u <mqtt-user> -p <mqtt-password> -tls 1

Expected behavior
Connection is steady as before and doesn't repeatedly disconnect.

Environment
:128: RuntimeWarning: 'TheengsGateway.diagnose' found in sys.modules after import of package 'TheengsGateway', but prior to execution of 'TheengsGateway.diagnose'; this may result in unpredictable behaviour

Theengs Gateway Diagnostics

Package Versions

Name Value
Theengs Gateway 1.6.0
Theengs Decoder 1.9.9
Bleak 1.0.1
Bluetooth Clocks 0.2.0
Bluetooth Numbers 1.1.2
Paho MQTT 2.1.0
Bluetooth Adapters 2.0.0

Python

Name Value
Version 3.12.3
Implementation CPython
Compiler GCC 13.3.0
Executable /home/user/theengs/bin/python

Operating System

Name Value
System Linux
Release 6.14.0-27-generic
Version #27~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 17:38:49 UTC 2
Machine type x86_64
Distribution Ubuntu 24.04.2 LTS

Configuration

File: /home/user/theengsgw.conf

{
    "adapter": "",
    "bindkeys": {},
    "blacklist": [],
    "ble": 1,
    "ble_scan_time": 7,
    "ble_time_between_scans": 5,
    "discovery": 1,
    "discovery_device_name": "TheengsGateway",
    "discovery_filter": [
        "IBEACON"
    ],
    "discovery_topic": "homeassistant",
    "enable_multi_gtw_sync": 1,
    "enable_tls": 1,
    "enable_websocket": 0,
    "gateway_id": "60:A5:E2:B0:43:F7",
    "general_presence": 0,
    "hass_discovery": 1,
    "host": "mqtt.lan",
    "identities": {},
    "ignore_wblist": 0,
    "log_level": "INFO",
    "lwt_topic": "home/TheengsGateway/LWT",
    "pass": "***",
    "port": 8883,
    "presence": 0,
    "presence_topic": "home/TheengsGateway/presence",
    "publish_advdata": 0,
    "publish_all": 1,
    "publish_topic": "home/TheengsGateway/BTtoMQTT",
    "scanning_mode": "active",
    "subscribe_topic": "home/+/BTtoMQTT/undecoded",
    "time_format": 0,
    "time_sync": [],
    "tls_insecure": 0,
    "tracker_timeout": 120,
    "trackersync_topic": "home/internal/trackersync",
    "user": "***",
    "whitelist": []
}

Bluetooth adapters

Default adapter: hci0

hci0

Name Value
address 60:A5:E2:XX:XX:XX
sw_version dashboard
hw_version usb:v1D6Bp0246d0548
passive_scan False
manufacturer Intel Corporate
product 0029
vendor_id 8087
product_id 0029

Additional context
Nothing really.

Thanks all! I did try debug output, but it doesn't give any more details about this (lots of info about devices it finds, but the MQTT connection activity logs remain the same).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions