I have successfully used mqtt when running weewx on a raspberry pi. I am now running weewx under docker on a more powerful pi4. The mqtt settings that worked originally now give the following error.
ValueError: Port could not be cast to integer value as '1883 ' - full error log below
1 There were no errors when paho-mqtt was installed.
Output from log file
May 31 11:26:43 weewx[18] ERROR weewx.restx: MQTT: Unexpected exception of type <class 'ValueError'>
May 31 11:26:43 weewx[18] ERROR weewx.restx: *** Traceback (most recent call last):
May 31 11:26:43 weewx[18] ERROR weewx.restx: *** File "/home/weewx/bin/weewx/restx.py", line 382, in run_loop
May 31 11:26:43 weewx[18] ERROR weewx.restx: *** self.process_record(_record, dbmanager)
May 31 11:26:43 weewx[18] ERROR weewx.restx: *** File "/home/weewx/bin/user/mqtt.py", line 522, in process_record
May 31 11:26:43 weewx[18] ERROR weewx.restx: *** self.get_mqtt_client()
May 31 11:26:43 weewx[18] ERROR weewx.restx: *** File "/home/weewx/bin/user/mqtt.py", line 453, in get_mqtt_client
May 31 11:26:43 weewx[18] ERROR weewx.restx: *** mc.connect(url.hostname, url.port)
May 31 11:26:43 weewx[18] ERROR weewx.restx: *** File "/usr/local/lib/python3.10/urllib/parse.py", line 177, in port
May 31 11:26:43 weewx[18] ERROR weewx.restx: *** raise ValueError(f"Port could not be cast to integer value as {port!r}")
May 31 11:26:43 weewx[18] ERROR weewx.restx: *** ValueError: Port could not be cast to integer value as '1883 '
May 31 11:26:43 weewx[18] CRITICAL weewx.restx: MQTT: Thread terminating. Reason: Port could not be cast to integer value as '1883 '
Exception in thread MQTT:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/home/weewx/bin/weewx/restx.py", line 355, in run
self.run_loop(_manager)
File "/home/weewx/bin/weewx/restx.py", line 382, in run_loop
self.process_record(_record, dbmanager)
File "/home/weewx/bin/user/mqtt.py", line 522, in process_record
self.get_mqtt_client()
File "/home/weewx/bin/user/mqtt.py", line 453, in get_mqtt_client
mc.connect(url.hostname, url.port)
File "/usr/local/lib/python3.10/urllib/parse.py", line 177, in port
raise ValueError(f"Port could not be cast to integer value as {port!r}")
ValueError: Port could not be cast to integer value as '1883 '