MQTT connection 'Data received: None'
Opened this issue · 1 comments
rjcds commented
Hi I'm having problems connecting to mqtt-eclipse (2.0.10) broker with this script.
I can connect to the broker with home-assistant core and other paho-mqtt clients in other containers.
MQTT logs:
1623105951: New connection from 172.28.0.1:58226 on port 11883.
1623105951: New client connected from 172.28.0.1:58226 as mqtt-explorer-75d44b10 (p2, c1, k60, u'vto').
1623105968: Client mqtt-explorer-75d44b10 disconnected.
1623106109: New connection from 192.168.1.19:35084 on port 11883.
1623106109: Client <unknown> disconnected due to protocol error.
1623106109: New connection from 192.168.1.19:37385 on port 11883.
1623106109: New client connected from 192.168.1.19:37385 as 3UKJjG0b6yndsYVxNFUnGH (p2, c1, k60, u'vto').
1623106114: New connection from 192.168.1.19:34616 on port 11883.
1623106114: Client <unknown> disconnected due to protocol error.
1623106114: New connection from 192.168.1.19:39968 on port 11883.
1623106114: New client connected from 192.168.1.19:39968 as 0QgPy6PuLVd5gaXFLZTHFe (p2, c1, k60, u'vto').
1623106115: Client 0QgPy6PuLVd5gaXFLZTHFe closed its connection.
1623106115: Client 3UKJjG0b6yndsYVxNFUnGH closed its connection.
(The mqtt-explorer connection was just to check that the credentials used for dahuavto2mqtt work independently).
Script stdout:
2021-06-08 08:50:29,521 INFO __main__ Connecting
2021-06-08 08:50:29,521 DEBUG asyncio Using selector: EpollSelector
2021-06-08 08:50:29,531 DEBUG __main__ Connection established
2021-06-08 08:50:29,531 INFO __main__ Initializing MQTT Broker
2021-06-08 08:50:29,531 INFO __main__ MQTT Broker is trying to connect...
2021-06-08 08:50:29,533 DEBUG __main__ Prepare pre-login message
2021-06-08 08:50:29,535 DEBUG __main__ Data received: None
2021-06-08 08:50:29,535 ERROR __main__ Failed to handle message, error: 'NoneType' object has no attribute 'get', Line: 212
2021-06-08 08:50:29,536 INFO __main__ Server sent EOF message
2021-06-08 08:50:29,536 ERROR __main__ server closed the connection
2021-06-08 08:50:29,536 WARNING __main__ Disconnected, will try to connect in 5 seconds
2021-06-08 08:50:29,538 INFO __main__ MQTT Broker connected with result code 0
2021-06-08 08:50:34,537 INFO __main__ Connecting
2021-06-08 08:50:34,537 DEBUG asyncio Using selector: EpollSelector
2021-06-08 08:50:34,540 DEBUG __main__ Connection established
2021-06-08 08:50:34,540 INFO __main__ Initializing MQTT Broker
2021-06-08 08:50:34,540 INFO __main__ MQTT Broker is trying to connect...
2021-06-08 08:50:34,541 DEBUG __main__ Prepare pre-login message
2021-06-08 08:50:34,543 DEBUG __main__ Data received: None
2021-06-08 08:50:34,543 ERROR __main__ Failed to handle message, error: 'NoneType' object has no attribute 'get', Line: 212
2021-06-08 08:50:34,543 INFO __main__ Server sent EOF message
2021-06-08 08:50:34,544 ERROR __main__ server closed the connection
2021-06-08 08:50:34,545 WARNING __main__ Disconnected, will try to connect in 5 seconds
The 'NoneType' error appears to be referring to this function:
def data_received(self, data):
try:
message = self.parse_response(data)
_LOGGER.debug(f"Data received: {message}")
message_id = message.get("id")
handler: Callable = self.data_handlers.get(message_id, self.handle_default)
handler(message)
Any suggestions on troubleshooting the mqtt connection ?
rjcds commented
With debug on in mosquitto.conf, I see:
1623107703: Sending CONNACK to 192.168.1.19 (0, 2)
1623107703: No will message specified.
1623107703: Sending CONNACK to 4R4bzh6WBoX8l8CTj0CeH7 (0, 0)
1623107703: Received SUBSCRIBE from 4R4bzh6WBoX8l8CTj0CeH7
1623107703: dahuavto/Command/Open (QoS 0)
1623107703: Sending SUBACK to 4R4bzh6WBoX8l8CTj0CeH7
1623107708: Sending CONNACK to 192.168.1.19 (0, 2)
1623107708: No will message specified.
1623107708: Sending CONNACK to 2THKtaiWtJwwgccsZHhx3G (0, 0)
1623107708: Received SUBSCRIBE from 2THKtaiWtJwwgccsZHhx3G
1623107708: dahuavto/Command/Open (QoS 0)
1623107708: Sending SUBACK to 2THKtaiWtJwwgccsZHhx3G