Belchertown skin with MQTT not working?

116 views
Skip to first unread message

Mark Jenks

unread,
Dec 21, 2020, 6:21:42 PM12/21/20
to weewx-user
What am I missing?  I can't seem to get this to work.  The website won't connect to mqtt to get the data.  Even though I can see it when I watch the topic.

Failed connecting to the weather station. Please try again later!  

[StdRESTful]
    [[MQTT]]
        server_url = mqtt://weather:passwordxxxxx@localhost:1883/
        topic = "weather/weewx"
        unit_system = US
        binding = archive, loop
        aggregation = aggregate

    [[Belchertown]]
        skin = Belchertown
        #        HTML_ROOT = /var/www/html/weewx/belchertown
        [[[Extras]]]
            mqtt_websockets_enabled = 1
            mqtt_websockets_host = "127.0.0.1"
            mqtt_websockets_port = 1883
            mqtt_websockets_topic = "weather/weewx/loop"

I see data when I run this, so it's getting populated.
#mosquitto_sub -h localhost -t weather/weewx/loop

Greg Troxel

unread,
Dec 21, 2020, 6:28:48 PM12/21/20
to Mark Jenks, weewx-user

Mark Jenks <mjenk...@gmail.com> writes:

> Failed connecting to the weather station. Please try again later!
>
> [StdRESTful]
> [[MQTT]]
> server_url = mqtt://weather:passwordxxxxx@localhost:1883/
> topic = "weather/weewx"
> unit_system = US
> binding = archive, loop
> aggregation = aggregate
>
> [[Belchertown]]
> skin = Belchertown
> # HTML_ROOT = /var/www/html/weewx/belchertown
> [[[Extras]]]
> mqtt_websockets_enabled = 1
> mqtt_websockets_host = "127.0.0.1"
> mqtt_websockets_port = 1883
> mqtt_websockets_topic = "weather/weewx/loop"
>
> I see data when I run this, so it's getting populated.
> #mosquitto_sub -h localhost -t weather/weewx/loop

I have not set this up, but I think what you are missing is that 1883 is
MQTT and you need to set up "mqtt over websockets" in mosquitto and
point the skin at that. And if you are using a browswer on the same
machine as the broker, ok, but really the mqtt_websockets_host needs to
be the global name and reachable.
signature.asc

Mark Jenks

unread,
Dec 21, 2020, 6:36:41 PM12/21/20
to weewx-user
I guess I should have included this...

# more mosquitto.conf
persistence false

# mqtt
listener 1883 127.0.0.1
protocol mqtt

# websockets
listener 9001 127.0.0.1
protocol websockets

vince

unread,
Dec 21, 2020, 7:13:24 PM12/21/20
to weewx-user
Assuming you have the MQTT broker side set up correctly....

With 90% certainty 'failure to connect' is because you are trying to connect to localhost (or 127.0.0.1) and rather than the ip address or FQDN of the webserver.   Belchertown works by establishing a connection from your browser to the remote websockets host, so you need to use the ip address of your MQTT listener there.

The javascript code that Belchertown runs in your browser can't connect to itself (127.0.0.1), it needs to connect to the server with the data.

vince

unread,
Dec 21, 2020, 7:18:10 PM12/21/20
to weewx-user
Old thread where I battled the same thing a year ago, with solution...


Mark Jenks

unread,
Dec 22, 2020, 9:31:14 AM12/22/20
to weewx-user
Okay, I cleaned it up per that link, and it doesn't seem to be working yet.

            mqtt_websockets_enabled = 1
            mqtt_websockets_host = weather.mjenks.net
            mqtt_websockets_port = 9001
            mqtt_websockets_ssl = 0
            mqtt_websockets_topic = "weather/weewx/loop"

It looks like it's listening correctly...

# netstat -tulpen|grep mosquitto
tcp        0      0 0.0.0.0:1883            0.0.0.0:*               LISTEN      0          27106828   2136787/mosquitto
tcp6       0      0 :::9001                 :::*                    LISTEN      0          27106831   2136787/mosquitto
tcp6       0      0 :::1883                 :::*                    LISTEN      0          27106829   2136787/mosquitto

# nc -4 -v weather.mjenks.net 9001
Ncat: Version 7.80 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.10.10:9001.

Tim Tuck

unread,
Dec 22, 2020, 2:15:21 PM12/22/20
to weewx...@googlegroups.com
Hi Mark,

Have you configured the operating system's firewall to permit the
connection ?

thanks

Tim

Mark Jenks

unread,
Dec 22, 2020, 7:20:42 PM12/22/20
to weewx-user
UGH, Thanks Tim.   :)

I usually don't run a firewall, because I use my home one.  But 6 months ago, I enabled it to stop all of the excess hacking attempted to ssh/http/etc/etc.  I started blocking countries, and repeat failures.

And that's what it was in the end.  Looks like I had multiple issues, but that was the last one.

Reply all
Reply to author
Forward
0 new messages