Belchertown MQTT live stats problem

191 views
Skip to first unread message

Scott Grayban

unread,
Jul 25, 2020, 4:26:40 AM7/25/20
to weewx-user
For over a year my live stats has been working flawlessly until recently. Now it says Failed connecting to the weather station

Looking at the dev console in chrome I am seeing this for the error and not sure how to test this out to see what is going on.

mqttws31.min.js:36 WebSocket connection to 'ws://X.X.X.X:9001/mqtt' failed: Connection closed before receiving a handshake response

The MQTT logs are only showing connections via port 1883.

Scott Grayban

unread,
Jul 26, 2020, 6:32:37 PM7/26/20
to weewx-user
Anyone?

Paul Anderson

unread,
Jul 26, 2020, 7:20:22 PM7/26/20
to weewx-user
Fist thing is check if your MQTT server is running, and that websockets is enabled.
If your running Mosquito on say Debian check etc/mosquitto/mosquitto.conf
Verify websockets is enabled on port 9001.
One possibility as to why it suddenly stopped working, I believe Debian had a recent update to MQTT server, if you updated it should have prompted you to keep your current configuration file or replace it with the new release version. If you didn't choose to keep your config, by default web sockets is disabled. Obviously if it's disabled just edit the config file, enable it and restart MQTT.

Scott Grayban

unread,
Jul 26, 2020, 7:50:33 PM7/26/20
to weewx-user
This is what I have in /myconfig.conf 

persistence false
allow_anonymous true
password_file /etc/mosquitto/passwd
acl_file /etc/mosquitto/acl
listener 1883 0.0.0.0
protocol mqtt
# websockets
listener 9001 0.0.0.0
protocol websockets

netstats shows

# netstat -ntap |grep 9001
tcp        0      0 0.0.0.0:9001            0.0.0.0:*               LISTEN      6928/mosquitto

wscat shows

# wscat -c "ws://63.230.134.165:9001"
connected (press CTRL+C to quit)
 
So I am assuming its working ?

Scott Grayban

unread,
Jul 26, 2020, 8:39:43 PM7/26/20
to weewx-user
Also I can subscribe to the weather/weewx/loop topic via MQTTBox app and I get responses. I wonder if something broke in jquery...

Paul Anderson

unread,
Jul 26, 2020, 9:10:57 PM7/26/20
to weewx-user
Sure seems like it's running and WebSockets is enabled for 9001. Must be some other issue. I actually don't even run belchertown, however I do run mosquito MQTT, and I recall quite a while ago being bitten by just the issue I mentioned where I upgraded and forgot to keep my existing config. Sorry I couldn't be of more help.

Scott Grayban

unread,
Jul 26, 2020, 9:21:24 PM7/26/20
to weewx-user
No worries... just very strange the live stats dont work anymore even though it works....

gary....@gmail.com

unread,
Jul 27, 2020, 3:00:37 PM7/27/20
to weewx-user
Try removing the IP from your config and try.

#  netstat -ntap | grep 9001
tcp6       0      0 :::9001                 :::*                    LISTEN      1365/mosquitto
tcp6       0      0 10.10.100.110:9001      10.10.100.1:10021       ESTABLISHED 1365/mosquitto

Scott Grayban

unread,
Jul 27, 2020, 10:35:28 PM7/27/20
to weewx-user
It didn't have the 0.0.0.0 originally and it still didn't work. I don't have ipv6 working on that pi so I thought something changed so I added 0.0.0.0

Like I said it works in MQTTBox just fine so I don't get the problem.

Don Roberts

unread,
Jul 28, 2020, 12:30:31 PM7/28/20
to weewx-user
I'm experiencing this same thing, and I'm using a public MQTT broker. Didn't change anything.

don

Graham Eddy

unread,
Jul 28, 2020, 12:55:59 PM7/28/20
to weewx...@googlegroups.com
maybe they turned off unencrypted mode.
try turning on SSL and use encrypted websockets port (8081 on test.mosquitto.org)

re logs, need option in mosquitto.conf ‘log_type all’ (or at least ‘log_type websockets’) plus (i haven’t tried this) ‘websockets_log_level {some flags}’ - latter defaults to off

--
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/73f84443-63ed-452f-8f2d-2cf65bfa0405o%40googlegroups.com.

Don Roberts

unread,
Jul 28, 2020, 4:57:18 PM7/28/20
to weewx...@googlegroups.com
Using developer mode, it looks like the MQTT server sends the string “Hello”, which causes the following line to crash:

    data = jQuery.parseJSON( data );

Don’t know if jQuery has changed recently, or the MQTT protocol. I’m not a webservices guru by any means.

don

Scott Grayban

unread,
Jul 28, 2020, 7:57:57 PM7/28/20
to weewx-user
@pat Can you give some help here?

Scott Grayban

unread,
Jul 28, 2020, 8:07:05 PM7/28/20
to weewx-user

vince

unread,
Jul 28, 2020, 8:10:28 PM7/28/20
to weewx-user
On Tuesday, July 28, 2020 at 1:07:05 PM UTC-7, Scott Grayban wrote:

I did a clean install on weewx v4 and belchertown latest, both with python3.
Live stats works just fine for me, without MQTT encryption being enabled.

Chotechai Piyavongsiri

unread,
Jul 29, 2020, 4:18:21 AM7/29/20
to weewx-user
Running fine with local mqtt broker, with or without encryption.

Chotechai Piyavongsiri

unread,
Jul 29, 2020, 4:29:25 AM7/29/20
to weewx-user
So it could be something changed on the public mqtt end.
Reply all
Reply to author
Forward
0 new messages