*Thanks Vince and Rich for the pointers and advice.*

It looks like the 2 biggest Ubuntu 21.04 changes that broke my setup were:
1.  Python changed from 3.8 to 3.9 
2.  mosquitto changed from version 1.6 to 2.0

The fixes that worked:
1.  reloading python3-paho-mqtt with command "sudo apt install 
python3-paho-mqtt" (rather than using pip3)
2.  edited my existing /etc/mosquitto/mosquitto.conf file:
        a.  I already had the line "allow_anonymous true" so that stayed 
as-is
        b.  changed the "port 1883" line to "listener 1883"
        c.  commented out the line with "include_dir /etc/mosquitto/conf.d"
3.  deleted the directory /run/mosquitto with "sudo rm -r /run/mosquitto"
4.  restarted the system

After that, mosquitto started without errors, the MTQQSubscribe service 
subscribed, and weewx was functional again.

After weewx was working in Ubuntu 21.04 I made a backup and tried upgrading 
to 21.10 - worked fine, without breakage!
So, now weewx 4.5.1 is running fine in Ubuntu 21.10.
On Saturday, January 1, 2022 at 12:56:45 PM UTC-6 Eric K wrote:

> I just restarted Ubuntu and made sure the mosquitto.conf file was adjusted 
> for the new 2.x listener command, and mosquitto started working.
>
> I just commented out a couple of lines I had in the mosquitto.conf file 
> (which worked fine in Ubuntu 20.10):
> #pid_file /var/run/mosquitto.pid
> #persistence true
> #persistence_location /var/lib/mosquitto/
> #log_dest file /var/log/mosquitto/mosquitto.log
>
> Earlier, I saw an error about creating /var/log/mosquitto/mosquitto.log 
>
> The mosquitto_sub command now works and mosquitto is receiving my 
> barometric pressure data!
>
> weewx@Ubuntu20-WEEWX:~$ mosquitto -c /etc/mosquitto/mosquitto.conf
> 1641062208: mosquitto version 2.0.10 starting
> 1641062208: Config loaded from /etc/mosquitto/mosquitto.conf.
> 1641062208: Opening ipv4 listen socket on port 1883.
> 1641062208: Error: Address already in use
> weewx@Ubuntu20-WEEWX:~$ mosquitto_sub -h 192.168.7.22 -p 1883 -t 
> tele/BMP280/SENSOR -d
> Client (null) sending CONNECT
> Client (null) received CONNACK (0)
> Client (null) sending SUBSCRIBE (Mid: 1, Topic: tele/BMP280/SENSOR, QoS: 
> 0, Options: 0x00)
> Client (null) received SUBACK
> Subscribed (mid: 1): 0
> Client (null) received PUBLISH (d0, q0, r0, m0, 'tele/BMP280/SENSOR', ... 
> (113 bytes))
>
> {"Time":"2022-01-01T12:38:02","BMP280":{"Temperature":69.7,"Pressure":985.8},"PressureUnit":"hPa","TempUnit":"F"}
> Client (null) sending PINGREQ
> Client (null) received PINGRESP
>
> weewx is running without errors and publishing reports every 300 seconds!
>
> Jan  1 12:35:07 Ubuntu20-WEEWX weewx[1224] DEBUG weewx.engine: Loading 
> service weewx.restx.StdPWSweather
> Jan  1 12:35:07 Ubuntu20-WEEWX weewx[1224] INFO weewx.restx: PWSWeather: 
> Data for station WESTGATE1 will be posted
> Jan  1 12:35:07 Ubuntu20-WEEWX weewx[1224] DEBUG weewx.engine: Finished 
> loading service weewx.restx.StdPWSweather
> Jan  1 12:40:22 Ubuntu20-WEEWX weewx[1224] INFO weewx.restx: PWSWeather: 
> Published record 2022-01-01 12:40:00 CST (1641062400)
> Jan  1 12:40:22 Ubuntu20-WEEWX weewx[1224] INFO weewx.restx: 
> Wunderground-PWS: Published record 2022-01-01 12:40:00 CST (1641062400)
> Jan  1 12:45:19 Ubuntu20-WEEWX weewx[1224] INFO weewx.restx: PWSWeather: 
> Published record 2022-01-01 12:45:00 CST (1641062700)
> Jan  1 12:45:19 Ubuntu20-WEEWX weewx[1224] INFO weewx.restx: 
> Wunderground-PWS: Published record 2022-01-01 12:45:00 CST (1641062700)
> On Saturday, January 1, 2022 at 11:56:36 AM UTC-6 Eric K wrote:
>
>> I just switched back to the Ubuntu 21.04 VM and collected lots of 
>> evidence of mosquitto not starting properly.
>>
>> These are the commands that Vince requested:
>>
>> weewx@Ubuntu20-WEEWX:/run$ ls -lagd /run/mosquitto
>> drwxr----- 2 mosquitto 40 Jan  1 11:37 /run/mosquitto
>>
>> weewx@Ubuntu20-WEEWX:/run$ ls -lagd /run/mosquitto/*
>> ls: cannot access '/run/mosquitto/*': Permission denied
>>
>> weewx@Ubuntu20-WEEWX:/run$ sudo rm -r /run/mosquitto
>>
>> weewx@Ubuntu20-WEEWX:/run$ sudo systemctl start mosquitto
>>
>> Job for mosquitto.service failed because the control process exited with 
>> error code.
>> See "systemctl status mosquitto.service" and "journalctl -xe" for details.
>>
>> weewx@Ubuntu20-WEEWX:/run$ sudo systemctl status mosquitto.service
>>
>> ● mosquitto.service - Mosquitto MQTT Broker
>>      Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; 
>> vendor preset: enabled)
>>      Active: failed (Result: exit-code) since Sat 2022-01-01 11:37:43 
>> CST; 16s ago
>>
>>        Docs: man:mosquitto.conf(5)
>>              man:mosquitto(8)
>>     Process: 3867 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto 
>> (code=exited, status=0/SUCCESS)
>>     Process: 3868 ExecStartPre=/bin/chown mosquitto: /var/log/mosquitto 
>> (code=exited, status=0/SUCCESS)
>>     Process: 3869 ExecStartPre=/bin/mkdir -m 740 -p /var/run/mosquitto 
>> (code=exited, status=0/SUCCESS)
>>     Process: 3870 ExecStartPre=/bin/chown mosquitto: /var/run/mosquitto 
>> (code=exited, status=0/SUCCESS)
>>     Process: 3871 ExecStart=/usr/sbin/mosquitto -c 
>> /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE)
>>    Main PID: 3871 (code=exited, status=1/FAILURE)
>>
>> Jan 01 11:37:43 Ubuntu20-WEEWX systemd[1]: mosquitto.service: Scheduled 
>> restart job, restart counter is at 5.
>> Jan 01 11:37:43 Ubuntu20-WEEWX systemd[1]: Stopped Mosquitto MQTT Broker.
>> Jan 01 11:37:43 Ubuntu20-WEEWX systemd[1]: mosquitto.service: Start 
>> request repeated too quickly.
>> Jan 01 11:37:43 Ubuntu20-WEEWX systemd[1]: mosquitto.service: Failed with 
>> result 'exit-code'.
>> Jan 01 11:37:43 Ubuntu20-WEEWX systemd[1]: Failed to start Mosquitto MQTT 
>> Broker.
>>
>> weewx@Ubuntu20-WEEWX:/run$ journalctl -xe
>> Hint: You are currently not seeing messages from other users and the 
>> system.
>>       Users in groups 'adm', 'systemd-journal' can see all messages.
>>       Pass -q to turn off this notice.
>> Jan 01 11:36:45 Ubuntu20-WEEWX dbus-daemon[2070]: [session uid=1001 
>> pid=2070] Successfully activated service 'org.freedesktop.Tracker1.Miner>
>> Jan 01 11:36:45 Ubuntu20-WEEWX systemd[2052]: Started Tracker metadata 
>> extractor.
>> ░░ Subject: A start job for unit UNIT has finished successfully
>> ░░ Defined-By: systemd
>> ░░ Support: http://www.ubuntu.com/support
>> ░░ 
>> ░░ A start job for unit UNIT has finished successfully.
>> ░░ 
>> ░░ The job identifier is 633.
>> Jan 01 11:36:55 Ubuntu20-WEEWX systemd[2052]: tracker-extract.service: 
>> Succeeded.
>> ░░ Subject: Unit succeeded
>> ░░ Defined-By: systemd
>> ░░ Support: http://www.ubuntu.com/support
>> ░░ 
>> ░░ The unit UNIT has successfully entered the 'dead' state.
>> Jan 01 11:36:59 Ubuntu20-WEEWX nautilus[3434]: The peer-to-peer 
>> connection failed: Could not connect: Permission denied. Falling back to 
>> the>
>> Jan 01 11:37:15 Ubuntu20-WEEWX tracker-store[3766]: OK
>> Jan 01 11:37:15 Ubuntu20-WEEWX systemd[2052]: tracker-store.service: 
>> Succeeded.
>> ░░ Subject: Unit succeeded
>> ░░ Defined-By: systemd
>> ░░ Support: http://www.ubuntu.com/support
>> ░░ 
>> ░░ The unit UNIT has successfully entered the 'dead' state.
>> Jan 01 11:37:28 Ubuntu20-WEEWX sudo[3841]:    weewx : TTY=pts/0 ; 
>> PWD=/run ; USER=root ; COMMAND=/usr/bin/rm -r /run/mosquitto
>> Jan 01 11:37:28 Ubuntu20-WEEWX sudo[3841]: pam_unix(sudo:session): 
>> session opened for user root by (uid=1001)
>> Jan 01 11:37:28 Ubuntu20-WEEWX sudo[3841]: pam_unix(sudo:session): 
>> session closed for user root
>> Jan 01 11:37:42 Ubuntu20-WEEWX sudo[3844]:    weewx : TTY=pts/0 ; 
>> PWD=/run ; USER=root ; COMMAND=/usr/bin/systemctl start mosquitto
>> Jan 01 11:37:42 Ubuntu20-WEEWX sudo[3844]: pam_unix(sudo:session): 
>> session opened for user root by (uid=1001)
>> Jan 01 11:37:42 Ubuntu20-WEEWX sudo[3844]: pam_unix(sudo:session): 
>> session closed for user root
>> Jan 01 11:38:00 Ubuntu20-WEEWX sudo[3874]:    weewx : TTY=pts/0 ; 
>> PWD=/run ; USER=root ; COMMAND=/usr/bin/systemctl status mosquitto.service
>> Jan 01 11:38:00 Ubuntu20-WEEWX sudo[3874]: pam_unix(sudo:session): 
>> session opened for user root by (uid=1001)
>> Jan 01 11:38:01 Ubuntu20-WEEWX sudo[3874]: pam_unix(sudo:session): 
>> session closed for user root
>> Jan 01 11:38:26 Ubuntu20-WEEWX dbus-daemon[2070]: [session uid=1001 
>> pid=2070] Activating service name='org.gnome.Nautilus' requested by ':1.>
>> Jan 01 11:38:26 Ubuntu20-WEEWX dbus-daemon[2070]: [session uid=1001 
>> pid=2070] Successfully activated service 'org.gnome.Nautilus'
>> Jan 01 11:38:27 Ubuntu20-WEEWX org.gnome.Nautilus[3883]: Traceback (most 
>> recent call last):
>> Jan 01 11:38:27 Ubuntu20-WEEWX org.gnome.Nautilus[3883]:   File 
>> "/usr/share/nautilus-python/extensions/nautilus-admin.py", line 25, in 
>> <modu>
>> Jan 01 11:38:27 Ubuntu20-WEEWX org.gnome.Nautilus[3883]:     from gettext 
>> import gettext, locale, bindtextdomain, textdomain
>> Jan 01 11:38:27 Ubuntu20-WEEWX org.gnome.Nautilus[3883]: ImportError: 
>> cannot import name 'locale' from 'gettext' (/usr/lib/python3.9/gettext>
>> Jan 01 11:38:27 Ubuntu20-WEEWX nautilus[3883]: Called "net usershare 
>> info" but it failed: Failed to execute child process “net” (No such fil>
>> Jan 01 11:41:55 Ubuntu20-WEEWX sudo[3932]:    weewx : TTY=pts/0 ; 
>> PWD=/run ; USER=root ; COMMAND=/usr/bin/systemctl start mosquitto
>> Jan 01 11:41:55 Ubuntu20-WEEWX sudo[3932]: pam_unix(sudo:session): 
>> session opened for user root by (uid=1001)
>> Jan 01 11:41:55 Ubuntu20-WEEWX sudo[3932]: pam_unix(sudo:session): 
>> session closed for user root
>> lines 3313-3354/3354 (END)
>>
>> weewx@Ubuntu20-WEEWX:/run$ mosquitto_sub -v -h 192.168.7.22 -p 1883 -t 
>> tele/BMP280/SENSOR -d
>> Error: Connection refused
>>
>> weewx@Ubuntu20-WEEWX:/etc/mosquitto$ mosquitto -c 
>> /etc/mosquitto/mosquitto.conf
>> 1641059552: mosquitto version 2.0.10 starting
>> 1641059552: Config loaded from /etc/mosquitto/mosquitto.conf.
>> 1641059552: Error: Unable to open pwfile "/etc/mosquitto/pwfile".
>> 1641059552: Error opening password file "/etc/mosquitto/pwfile".
>>
>> weewx@Ubuntu20-WEEWX:/etc/mosquitto$ sudo mosquitto -c 
>> /etc/mosquitto/mosquitto.conf
>> 1641059578: mosquitto version 2.0.10 starting
>> 1641059578: Config loaded from /etc/mosquitto/mosquitto.conf.
>> 1641059578: Error: Unable to open pwfile "/etc/mosquitto/pwfile".
>> 1641059578: Error opening password file "/etc/mosquitto/pwfile".
>>
>> On Saturday, January 1, 2022 at 11:09:48 AM UTC-6 bell...@gmail.com 
>> wrote:
>>
>>> Now that the broker is running, does mosquitto_sub work?
>>> Also, as Vince suggested, adding the  -v option (verbose) to the 
>>> mosquitto command would be useful.
>>> rich
>>> On Saturday, 1 January 2022 at 11:40:16 UTC-5 Eric K wrote:
>>>
>>>> When using, the MQTTSubscirbe driver in weewx, it runs as a weewx 
>>>> service in the same machine as weewx.
>>>> see: https://github.com/bellrichm/WeeWX-MQTTSubscribe
>>>> I'm running the mosquitto broker in the same Ubuntu VM as weewx, 
>>>> because its convenient, and it works fine in my Ubuntu 20.10 VM.
>>>>
>>>> I have a barometric pressure sensor (a stand-alone wifi device on a 
>>>> different IP from the Ubuntu VM) that sends data to weewx via MQTT and the 
>>>> MQTTSubscribe driver.
>>>> So, I need to get that to properly connect with mosquitto in Ubuntu 
>>>> 21.04, like it does in the Ubuntu 20.10.
>>>>
>>>> The connection we saw when I tried running mosquitto with it's internal 
>>>> default settings was MQTTSubscribe trying to connect to it.
>>>>
>>>> weewx@Ubuntu20-WEEWX:~$ mosquitto
>>>> 1640984406: mosquitto version 2.0.10 starting
>>>> 1640984406: Using default config.
>>>> 1640984406: Starting in local only mode. Connections will only be 
>>>> possible from clients running on this machine.
>>>> 1640984406: Create a configuration file which defines a listener to 
>>>> allow remote access.
>>>> 1640984406: For more details see 
>>>> https://mosquitto.org/documentation/authentication-methods/
>>>> 1640984406: Opening ipv4 listen socket on port 1883.
>>>> 1640984406: Opening ipv6 listen socket on port 1883.
>>>> 1640984406: mosquitto version 2.0.10 running
>>>> 1640984413: New connection from 127.0.0.1:42095 on port 1883.
>>>>
>>>> *1640984413: New client connected from 127.0.0.1:42095 
>>>> <http://127.0.0.1:42095/> as MQTTSubscribe-5503 (p2, c1, k60, 
>>>> u'None').1640984418: Client MQTTSubscribe-5503 disconnected.*
>>>> On Saturday, January 1, 2022 at 4:39:39 AM UTC-6 jon.bar...@gmail.com 
>>>> wrote:
>>>>
>>>>> Eric,
>>>>>
>>>>> In one of your posts above, the mosquito broker says it has a 
>>>>> connection from a client...and given you're running this in a single VM, 
>>>>> that must be a client on that machine.
>>>>> Im struggling to understand why you would want a MQTT broker on the 
>>>>> same VM as weewx ...when it only needs the client.  as weewx doesnt 
>>>>> respond 
>>>>> to mqtt messages/commands (someone will correct me if Im wrong) - maybe 
>>>>> you 
>>>>> dont need mqtt at all ?
>>>>> I suggest you test wether the weewx client is working (publishing) by 
>>>>> using one of the public MQTT brokers such as test.moquito.org (and 
>>>>> monitor your messages via mqtt explorer.
>>>>> If you're running the broker in the same vm as weewx, then you must 
>>>>> have other mqtt devices (clients)...do they work ?
>>>>> I agree with Vince...and Im starting to lose the plot over what you're 
>>>>> trying to acheive....
>>>>>
>>>>>
>>>>> On Friday, 31 December 2021 at 23:47:59 UTC vince wrote:
>>>>>
>>>>>> Work your mosquitto broker problem and that only.
>>>>>> Test with mosquitto_sub and mosquitto_pub and get that to work first.
>>>>>> Once that works, try to get weewx to subscribe.
>>>>>>
>>>>>> Try removing any previous garbage your earlier attempts might have 
>>>>>> put into /run.
>>>>>>
>>>>>> sudo rm -r /run/mosquitto
>>>>>> sudo systemctl start mosquitto
>>>>>>
>>>>>> On my ubuntu 21.10 vm permissions look like:
>>>>>>
>>>>>> root@ubuntu-focal:/run# ls -lagd /run/mosquitto
>>>>>> drwxr----- 2 root 60 Dec 31 23:42 /run/mosquitto
>>>>>>
>>>>>> root@ubuntu-focal:/run# ls -lagd /run/mosquitto/*
>>>>>> -rw-r--r-- 1 mosquitto 4 Dec 31 23:42 /run/mosquitto/mosquitto.pid
>>>>>>
>>>>>> On Friday, December 31, 2021 at 2:36:19 PM UTC-8 Eric K wrote:
>>>>>>
>>>>>>> No, its not working.  
>>>>>>> Running the commands with sudo still failed to generate a pid file.
>>>>>>> Running with the default config allowed mosquitto to start and 
>>>>>>> MQTTSubscribe tried to connect but it disconnected after 5 seconds.
>>>>>>>
>>>>>>> When I started weewx and forced wee_reports to run, it bomed out 
>>>>>>> with many errors including MQTTSubscribe errors.
>>>>>>> I suspect because it couldn't connect to mosquitto.
>>>>>>>
>>>>>>> Since the mosquitto command changed from "port" to "listener", do I 
>>>>>>> have to change the MQTTSubscribe section of weewx.conf so it calls out 
>>>>>>> "listener = 1883" rather than "port = 1883"?
>>>>>>>
>>>>>>>
>>>>>>> On Friday, December 31, 2021 at 4:20:01 PM UTC-6 vince wrote:
>>>>>>>
>>>>>>>> So is it working ?  Not working ?
>>>>>>>> We can't read minds and your followups are rather cryptic.
>>>>>>>>
>>>>>>>> Is there any mosquitto process running ?
>>>>>>>> If so stop it and try again with 'sudo systemctl start mosquitto' 
>>>>>>>>
>>>>>>>> If you want to try to run mosquitto in the foreground to debug it, 
>>>>>>>> add the -v switch to make it verbose, and remember to use sudo
>>>>>>>>
>>>>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/258f7a6f-db37-457e-81fa-d3ee9fa3db24n%40googlegroups.com.

Reply via email to