tjhowse / modbus4mqtt

Modbus TCP <-> MQTT glue. YAML configuration. Robust.
Other
75 stars 33 forks source link

Graceless handling of the MQTT broker disconnecting #19

Closed tjhowse closed 3 years ago

tjhowse commented 3 years ago

2020-11-20 09:59:18 INFO     Connected to MQTT.
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.5/dist-packages/paho/mqtt/client.py", line 3452, in _thread_main
    self.loop_forever(retry_first_connection=True)
  File "/usr/local/lib/python3.5/dist-packages/paho/mqtt/client.py", line 1779, in loop_forever
    rc = self.loop(timeout, max_packets)
  File "/usr/local/lib/python3.5/dist-packages/paho/mqtt/client.py", line 1181, in loop
    rc = self.loop_read(max_packets)
  File "/usr/local/lib/python3.5/dist-packages/paho/mqtt/client.py", line 1574, in loop_read
    return self._loop_rc_handle(rc)
  File "/usr/local/lib/python3.5/dist-packages/paho/mqtt/client.py", line 2227, in _loop_rc_handle
    self._do_on_disconnect(rc, properties)
  File "/usr/local/lib/python3.5/dist-packages/paho/mqtt/client.py", line 3360, in _do_on_disconnect
    self.on_disconnect(self, self._userdata, rc)
TypeError: _on_disconnect() missing 1 required positional argument: 'rc```

We shouldn't crash on disconnect, and we should try to reconnect.
tjhowse commented 3 years ago

This should be fixed, but leaving it open until the reporter confirms v0.3.5 fixes it.

tjhowse commented 3 years ago

Fix is confirmed. Thanks Виктор!