Belchertown MQTT not generating real time data...

269 views
Skip to first unread message

Gordon Dickens

unread,
Jan 18, 2020, 8:48:36 AM1/18/20
to weewx-user
Hello everybody,

I have the Belchertown skin up and running nicely and so I decided to enable MQTT.  I successfully installed mosquitto and endeavored to enable MTTQ with Belchertown/weewx.  However, Belchertown/weewx is not doing realtime updates as it is supposed to and displays either "Connecting to weather station real time data" (with firefox) or "Failed connecting to the weather station. Please try again later!" (with chrome, chromium or Konqueror) according to which browser I am using.

I am confident that mosquitto is working properly since I am able to manually receive mosquitto output with the command, "mosquitto_sub -h localhost -t weather/#", which generates lots of weather data every two seconds. Also, my logs show MQTT posting every two seconds as follows:

Jan 17 17:46:27 zeebytes.org weewx[22287]: restx: MQTT: Published record 2020-01-17 17:46:27 EST (1579301187)

Here is my MQTT setup in weewx.conf:

    [[MQTT]]
        server_url = mqtt://<user>:<password>@localhost:1883/
        topic = weather
        unit_system = US
        binding = archive, loop
        aggregation = aggregate

Here is my MQTT setup in the Belchertown skin.conf:

# MQTT Websockets defaults
    mqtt_websockets_enabled = 1
    mqtt_websockets_host = "localhost"
    mqtt_websockets_port = 9001
    mqtt_websockets_ssl = 0
    mqtt_websockets_topic = "weather/#"
    disconnect_live_website_visitor = 1800000
 
I am running Debian 10 and apache2.

You may view the site at https://zeebytes.org

I hope that someone can tell me what I am doing wrong!

Thanks,

Gordon








G Hammer

unread,
Jan 18, 2020, 12:53:21 PM1/18/20
to weewx-user
I think it is because you are going to the site via https but do not have ssl enabled for the skin mqtt_websockets_ssl = 0 vs mqtt_websockets_ssl = 1
I'd also change the topic to weather/loop vs weather/#

G Hammer

unread,
Jan 18, 2020, 12:55:36 PM1/18/20
to weewx-user
I also had to change from mqtt_websockets_host = "localhost" to mqtt_websockets_host = "FQDN" with FQDN being the full public name of the server.


On Saturday, January 18, 2020 at 8:48:36 AM UTC-5, Gordon Dickens wrote:

Gordon Dickens

unread,
Jan 19, 2020, 10:36:14 AM1/19/20
to weewx-user
I got it working.  I'm not sure exactly why but I think the problem was related to running the site with https while running Belchertown with mqtt_websockets_ssl = 0.  As soon as I amended my apache2 config so that weewx was running unencrypted with htttp instead of https then it started working.  I plan to subsequently amend apache2 and weewx/Belchertown to run encrypted with ssl and https.  As an FYI,
my weewx/Belchertown config files that worked are as follows:

weewx.conf:

[[MQTT]]
        server_url = mqtt://<user>:<password>@localhost:1883/
        topic = weather
        unit_system = US
        binding = archive, loop
        aggregation = aggregate

Belchertown skin.conf:

# MQTT Websockets defaults
    mqtt_websockets_enabled = 1
    mqtt_websockets_host = "zeebytes.org"

    mqtt_websockets_port = 9001
    mqtt_websockets_ssl = 0
    mqtt_websockets_topic = "weather/loop"
    disconnect_live_website_visitor = 1800000

G Hammer

unread,
Jan 19, 2020, 11:07:52 AM1/19/20
to weewx-user
Glad to hear it is working now.

Gordon Dickens

unread,
Jan 21, 2020, 8:54:02 AM1/21/20
to weewx...@googlegroups.com, G Hammer
Hi Gary,

Thanks very much for your reply!  As you suggested, I set the host name to be my FQDN,"zeebytes.org", instead of "localhost". I also added a non-ssl url with http://zeebytes.org (as opposed to https://zeebytes.org) and I set the mqtt_websockets_topic = "weather/loop", however, it still does not do any real time updating.  So, here are my config files:


weewx.conf:

[[MQTT]]
        server_url = mqtt://<user>:<password>@localhost:1883/
        topic = weather
        unit_system = US
        binding = archive, loop
        aggregation = aggregate

Belchertown skin.conf:

# MQTT Websockets defaults
    mqtt_websockets_enabled = 1
    mqtt_websockets_host = "zeebytes.org"

    mqtt_websockets_port = 9001
    mqtt_websockets_ssl = 0
    mqtt_websockets_topic = "weather/loop"
    disconnect_live_website_visitor = 1800000

You may now view the site at: http://zeebytes.org

Does anyone have any other ideas as to what I am doing wrong?

Thanks,

Gordon
--
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/fbc8ce3d-bfb6-4dd0-9725-c23dfa5c66b4%40googlegroups.com.

Ryan Kramer

unread,
Jan 21, 2020, 11:03:05 AM1/21/20
to weewx-user
Looking at your site, you have something wrong in your config yet.   Per the includes, you have crabapple.dickens.com as your MQTT server.  Doesn't look like that is responding to anything.


    client = new Paho.MQTT.Client("crabapple.dickens.com", 9001, mqttclient);



G Hammer

unread,
Jan 21, 2020, 9:32:45 PM1/21/20
to weewx-user
When I go to the site you gave zeebytes.org, I actually get crabapple.dickens.com
Redirects are possible, but I have no idea where to start since I haven't configured any for my domain.

That is where MQTT is attempting to connect as well.

mqttws31.min.js:36 WebSocket connection to 'wss://crabapple.dickens.com:9001/mqtt' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT



Gordon Dickens

unread,
Jan 22, 2020, 7:31:00 AM1/22/20
to weewx-user
Hi Ryan Kramer and G. Hammer,

Thanks for replying, however, I got everything working three days ago on January 19 as per this post:


Then, yesterday, I spent most of the day switching the domain from zeebytes.org to crabapple.dickens.com and installing a new SSL certificate for crabapple.dickens.com.  You both apparently missed my earlier post within which I said that I had it fixed (under the zeebytes.org domain) and then subsequently started trying to diagnose my installation while I was simultaneously switching domain names and, therefore, encountered the issues that you discussed.  I am sure that the issues that you saw were bizarre since I was reinstallling everything while you watched and tried to evaluate the site...

I believe that everything is working properly now, however, it is a brand new installation configuration and so I will not be surprised if we don't see other issues before I get it totally sorted out over the next few days.

Thanks again!

Gordon

G Hammer

unread,
Jan 22, 2020, 7:49:47 AM1/22/20
to weewx...@googlegroups.com
No, I still don't get MQTT data when I connect using the Dickens domain address.


--
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/HRhNyrWRIn0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/b1090316-8534-46de-9595-ab8e60bdb5f0%40googlegroups.com.

Gordon Dickens

unread,
Jan 22, 2020, 8:25:03 AM1/22/20
to weewx-user
Hello Mr. Hammer,

Its working on all of my devices and my wife's devices both under Linux, Windows, Android and iphone.  Please try a different browser and/or clear the cache and delete browser history for crabapple.dickens.com.  Otherwise, I cannot recreate what you are seeing.

Thanks!

Gordon
To unsubscribe from this group and all its topics, send an email to weewx...@googlegroups.com.

G Hammer

unread,
Jan 22, 2020, 8:34:14 AM1/22/20
to weewx...@googlegroups.com
Using a different computer then my phone, no data.


To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/a98a305c-04ea-4684-a761-fea67befc63b%40googlegroups.com.
Screenshot_20200122-083146.jpg

Gordon Dickens

unread,
Jan 22, 2020, 2:47:03 PM1/22/20
to weewx-user
Hello Mr. Hammer,

I believe that I have fixed everything.  Please check my site now at


For some reason, I thought that the websocket port was udp and so I therefore set up iptables wrong.  As soon as I changed the websockets iptables rule to tcp then everything started working from outside of my firewall.  As I mentioned, everything had been working from behind my firewall on my local network since January 19 and I did not realize that I had dumb-thumbed the websocket iptables rules until you pointed it out. I should have tested for that but......

Thanks again for reviewing my site and letting me know that it wasn't working properly!

Gordon



It must be a firewall issue since it works great from inside my local network. Just so you know, I have been able to reproduce it not working from outside my firewall.  I will fix this today and let you know when its working.  Thanks very much for taking the time to le me know!

Gordon

G Hammer

unread,
Jan 22, 2020, 11:11:22 PM1/22/20
to weewx...@googlegroups.com
Working great from here.
I too have incorrigible fingers when writing configs.

To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/97c07241-0558-48db-9690-f03074a44f80%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages