MQTT Mosquitto - my experience and advice to starters

331 views
Skip to first unread message

Xant

unread,
Aug 1, 2019, 1:10:01 PM8/1/19
to weewx-user

It's hard to catch a fly... as somehow not simple to deal with Mosquitto (or is it?)

Thank Pat for howto to install own MQTT own server, but still defies me... everything seems correct, but no way yet to connect (and the usual learning curve and debugging hours...)

My experience and feedback is DON'T start with MQTT trying to install your own server at first (as I did), but start with any free public MQTT server, punch in you config, and connect in a few quick minutes.

First, I tried 'test.mosquitto.org', and it worked out-of-the-box. A few days ago, my weather web starting having no connection.... more hours debugging, trying to recollect what I changed what recently changed and reverse at no prevail.

Later, as last resort, changed to 'broker.hivemq.com', and connect! (not sure if a problem with 'test.mosquitto.org', or on my side).

My MQTT weewx.conf:

    [[MQTT]]
        server_url = mqtt://broker.hivemq.com:1883/
        topic = weather
        unit_system = US
        binding = loop
        aggregation = aggregate

My Belchertown skin.conf:

    # MQTT Websockets defaults
    mqtt_websockets_enabled = 1
    mqtt_websockets_host = broker.hivemq.com
    mqtt_websockets_port = 8000
    mqtt_websockets_ssl = 0
    mqtt_websockets_topic = weather/loop
    disconnect_live_website_visitor = 1800000


Later, if time, may try to play with local MQTT server again.... but just maybe...

Best,
Xant

Xant

unread,
Aug 20, 2019, 12:50:15 AM8/20/19
to weewx-user

Finally, working locally (after too much tweaking time...)

The trick, as pointed by someone in different Forum, is NOT to use "localhost" in Websockets, as it may have a conflict with IPv6 in RaspberryPi. Instead of "localhost", use IP of WeeWX device.


My MQTT weewx.conf (for local MQTT):

    [[MQTT]]
        server_url = mqtt://[user:password]@localhost:1883/

        topic = weather
        unit_system = US
        binding = loop
        aggregation = aggregate

My Belchertown skin.conf (for local MQTT):

    # MQTT Websockets defaults
    mqtt_websockets_enabled = 1
    mqtt_websockets_host = [your WeeWX IP]   #(NOT "localhost")
    mqtt_websockets_port = 9001
    mqtt_websockets_ssl = 0
    mqtt_websockets_topic = "weather/loop"   #(or "weather/#")
    disconnect_live_website_visitor = 1800000

Open port 9001 in router.

Best,
Xant

Greg Troxel

unread,
Aug 20, 2019, 10:50:17 AM8/20/19
to Xant, weewx-user
Xant <armando...@gmail.com> writes:

> The trick, as pointed by someone in different Forum, is NOT to use
> "localhost" in Websockets, as it may have a conflict with IPv6 in
> RaspberryPi. *Instead of "localhost", use IP of WeeWX device.*

I have found that mosquitto works fine over IPv6. The problem is
probably that localhost expands to "::1, 127.0.0.1" and your mosquitto
config might not listen on v6.

Something else that confuses me, though, is that I'd expect that the
value of mqtt_websockets_host would be sent to browsers and thus would
have to be a global name. But that's not related to v4/v6 issues, mostly.
Message has been deleted

Xant

unread,
Aug 20, 2019, 12:24:20 PM8/20/19
to weewx-user
Greg

Thank you for note, and apologies for confusion as you might be right.

After your note, realized that I didn't test website "outside" of home network (I guess was too excited of local MQTT finally responding). And sure, MQTT now responding inside network, but not outside.

Thus, replaced device IP with "global name"/site DNS and now working in&out (somehow had a problem before, but working now).

Update:


    # MQTT Websockets defaults
    mqtt_websockets_enabled = 1
    mqtt_websockets_host = [global Name/site DNS]   #(NOT "localhost")

    mqtt_websockets_port = 9001
    mqtt_websockets_ssl = 0
    mqtt_websockets_topic = "weather/loop"   #(or "weather/#")
    disconnect_live_website_visitor = 1800000

Thanks,
Xant

Xant

unread,
Aug 20, 2019, 12:32:31 PM8/20/19
to weewx-user

Update note to Starters:

1) At first, use a Public MQTT broker

2) Once MQTT working from a Test provider, consider installing locally (in my case, noticed working most of the time - and great to start with, but later having instabilities from external MQTT).

Best,
Xant

Xant

unread,
Aug 20, 2019, 9:45:58 PM8/20/19
to weewx-user

All works well.... till reboot. Unable to load driver error. Not sure if MQTT, but most suspicious....

Aug 20 21:35:32 raspberrypi weewx[446]: engine: Locale is 'en_US.UTF-8'
Aug 20 21:35:32 raspberrypi weewx[446]: engine: pid file is /var/run/weewx.pid
Aug 20 21:35:32 raspberrypi weewx[330]: Starting weewx weather system: weewx.
Aug 20 21:35:32 raspberrypi systemd[1]: Started LSB: weewx weather system.
Aug 20 21:35:32 raspberrypi weewx[469]: engine: Using configuration file /etc/we
Aug 20 21:35:32 raspberrypi weewx[469]: engine: Loading station type ObserverIP
Aug 20 21:35:33 raspberrypi weewx[469]: observerip: version is 0.6
Aug 20 21:35:33 raspberrypi weewx[469]: engine: Import of driver failed: [Errno
Aug 20 21:35:33 raspberrypi weewx[469]: engine: Unable to load driver: [Errno 10
Aug 20 21:35:33 raspberrypi weewx[469]:     ****  Exiting...

If I kill and restart Mosquitto and WeeWX (in this order), still gives error, but will engage at sometime (and "luck").

Wondering if there is a Reboot sequence issue, and someone to advice as to verify Mosquitto service ahead of WeeWX (if that matters).

Thanks,
Xant

Paul Lacatus (Gmail)

unread,
Aug 21, 2019, 2:15:18 PM8/21/19
to weewx...@googlegroups.com

Hi Xant, Pat and everybody other

I am trying to connect Belchertown skin to my home mqtt browser . I am using at home RabbitMQ as mqtt broker. I activated the websockets mqtt plugin  https://www.rabbitmq.com/web-mqtt.html

my Extras section from Belchertown shin looks like :

[[[Extras]]]
        belchertown_root_url= http://meteopi.paul.local/weewx/belchertown/
        earthquake_enabled = 1
        forecast_enabled = 1
        darksky_secret_key = ##########################
        site_title = "Home, sweet home"
         webpage_autorefresh = 30000
         mqtt_websockets_enabled = 1
         mqtt_websockets_host = 10.100.100.10
         mqtt_websockets_port = 15675
         mqtt_websockets_topic = home/weewx

the weewx mqtt section is

 [[MQTT]]
        server_url = mqtt://mqtt:mq...@10.100.100.10:1883/
        topic = home/weewx
        unit_system = METRIC
        binding = loop, archive
#    aggregation = individual, aggregate

I can see on the broker the messages publised by weewx but Belchertoen skin indicates that is failed to connect to the broker over websockets. I suspect that is required an authentication by used and password that is also needed over mqtt. as you can see in the weewx mqtt section.

I don't know how to authenticate Belchertown skin .

Thanks for any suggestion

Paul

--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/37a4e471-f3e2-441a-8d9f-dce5a00ebaad%40googlegroups.com.

Xant

unread,
Dec 16, 2019, 10:20:48 PM12/16/19
to weewx-user
Reply all
Reply to author
Forward
0 new messages