MQTT says connected but, it never actually publishes if DEBUG=False. If DEBUG=True then it connects and works as expected
Weird issue. As title states, if DEBUG=False
, the container doesn't work. If DEBUG=True
, the container works as expected.
Broker logs
023-09-07 18:13:17: New client connected from 10.0.1.14:48761 as DahuaVTO2MQTT (p2, c1, k60, u'dahuavto').
DEBUG=False
docker logs when root@gotify:~/docker/dahuavto# docker logs dahuavto2mqtt -f
2023-09-16 21:06:08,045 INFO clients.BaseClient Initialize MQTTClient
2023-09-16 21:06:08,045 INFO clients.BaseClient Starting to connect MQTTClient, Should connect: True
2023-09-16 21:06:08,046 INFO clients.BaseClient Initialize DahuaClient
2023-09-16 21:06:08,046 INFO clients.BaseClient Starting to connect DahuaClient, Should connect: True
2023-09-16 21:06:09,046 INFO clients.MQTTClient MQTT Broker is trying to connect...
2023-09-16 21:06:09,047 INFO clients.DahuaClient Connecting
2023-09-16 21:06:09,228 INFO clients.MQTTClient MQTT Broker connected with result code 0
2023-09-16 21:06:09,673 INFO clients.DahuaAPI Get access control configuration
2023-09-16 21:06:09,674 INFO clients.DahuaAPI Get version
2023-09-16 21:06:09,674 INFO clients.DahuaAPI Get serial number
2023-09-16 21:06:09,674 INFO clients.DahuaAPI Get device type
2023-09-16 21:06:09,674 INFO clients.DahuaAPI Attach event manager
2023-09-16 21:06:09,843 INFO clients.DahuaAPI Version: 1.000.010000000.8.R, Build Date: 2022-09-03
2023-09-16 21:06:09,892 ERROR clients.DahuaAPI Failed to handle message, error: 'NoneType' object is not iterable, Line: 90
2023-09-16 21:06:09,937 INFO clients.DahuaAPI Device Type: B451AJ
So, dahuavto2mqtt is connecting to the broker with credentials and says it gets an empty message when DEBUG=False
. It stalls there and never publishes anything to MQTT broker.
DEBUG=True
docker logs when If I set DEBUG=True
and recreate the container, everything works as expected. There is an error message that seems to be around where it freezes when DEBUG=False
:
# Logs when DEBUG=True, showcasing an error msg
root@gotify:~/docker/dahuavto# docker logs dahuavto2mqtt -f
2023-09-16 21:07:49,476 INFO clients.BaseClient Initialize MQTTClient
2023-09-16 21:07:49,476 INFO clients.BaseClient Starting to connect MQTTClient, Should connect: True
2023-09-16 21:07:49,476 INFO clients.BaseClient Initialize DahuaClient
2023-09-16 21:07:49,477 INFO clients.BaseClient Starting to connect DahuaClient, Should connect: True
2023-09-16 21:07:50,476 INFO clients.MQTTClient MQTT Broker is trying to connect...
2023-09-16 21:07:50,477 INFO clients.DahuaClient Connecting
2023-09-16 21:07:50,478 DEBUG asyncio Using selector: EpollSelector
2023-09-16 21:07:50,479 INFO clients.MQTTClient MQTT Broker connected with result code 0
2023-09-16 21:07:50,483 DEBUG clients.DahuaAPI Connection established
2023-09-16 21:07:50,483 DEBUG clients.DahuaAPI Prepare pre-login message
2023-09-16 21:07:50,519 DEBUG clients.DahuaAPI Data received: {'error': {'code': 268632079, 'message': 'Component error: login challenge!'}, 'id': 2, 'params': {'authorization': '37a266f79d50f73e70e91f40b038d5294157eea9', 'encryption': 'Default', 'random': '479607427', 'realm': 'Login to ND032204015447'}, 'result': False, 'session': 1173454752}
2023-09-16 21:07:50,519 DEBUG clients.DahuaAPI Prepare login message
2023-09-16 21:07:50,530 DEBUG clients.DahuaAPI Data received: {'id': 3, 'params': {'isPwdOverdue': False, 'keepAliveInterval': 60}, 'result': True, 'session': 1173454752}
2023-09-16 21:07:50,530 INFO clients.DahuaAPI Get access control configuration
2023-09-16 21:07:50,530 INFO clients.DahuaAPI Get version
2023-09-16 21:07:50,531 INFO clients.DahuaAPI Get serial number
2023-09-16 21:07:50,531 INFO clients.DahuaAPI Get device type
2023-09-16 21:07:50,531 INFO clients.DahuaAPI Attach event manager
2023-09-16 21:07:50,543 DEBUG clients.DahuaAPI Data received: {'id': 5, 'params': {'version': {'Build': '20220903', 'BuildDate': '2022-09-03', 'Version': '1.000.010000000.8.R', 'WebVersion': None}}, 'result': True, 'session': 1173454752}
2023-09-16 21:07:50,543 INFO clients.DahuaAPI Version: 1.000.010000000.8.R, Build Date: 2022-09-03
Edited by baudneo