Problem with MQTT

88 views
Skip to first unread message

Kalju

unread,
Jun 14, 2019, 2:35:28 PM6/14/19
to weewx-user
Hi everybody,

Here's my problem - and I have to admit I'm not a developer by any means... :-)
I can not get mqtt working on my site

Here are my settings - mind you, I'm not using SSL:

weewx.conf
    [[MQTT]]
        server_url = mqtt://weewx:weather@localhost:1883/
        topic = weather
        unit_system = US
        binding = archive, loop
        aggregation = aggregate
        #log_success = False
        log_failure = True


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

mosquitto.conf
persistence false

allow_anonymous true

password_file /volume1/@appstore/mosquitto/var/passwd
 
acl_file /volume1/@appstore/mosquitto/var/acl
 
# Insecure mqtt to localhost only, and secure mqtt
listener 1883
protocol mqtt
 
# websockets
listener 9001
protocol websockets

websocket 9001 receives messages (mqtt-spy)

spy.png


mqtt 1883 receives messages (mqtt)

mqtt.png



But there is no connection. From Chrome developer console I see that the access to ws://localhost:9001/mqtt is declined...

What I'm doing wrong?

Pat

unread,
Jun 14, 2019, 7:52:27 PM6/14/19
to weewx-user
Hi Kalju, 

First change your mqtt_websockets_topic = "weather/#" to weather/loop. (Just curious, did you follow a tutorial of mine somewhere? I see a lot of folks using # when it shouldn't be used. Wondering if I need to clean that up somewhere)

Second, mosquitto is very, very picky. Double check your mosquitto.conf file that there's no whitespace at the end of each line, make sure every empty line doesn't contain a blank space, etc.

Third, "when in doubt, reboot". You'll be surprised at how often a reboot fixes many mosquitto problems.

Pat

unread,
Jun 14, 2019, 7:59:03 PM6/14/19
to weewx-user
Also sidenote that using Chrome's developer tools, you won't be able to access any ws:// or wss:// endpoint directly. It's not like http. You can download this websocket test website to your server's http folder and try it to see if it'll connect. This will take weewx and Belchertown out of it for testing


On Friday, June 14, 2019 at 2:35:28 PM UTC-4, Kalju wrote:

mwall

unread,
Jun 15, 2019, 2:51:04 PM6/15/19
to weewx-user
On Friday, June 14, 2019 at 7:52:27 PM UTC-4, Pat wrote:

Third, "when in doubt, reboot". You'll be surprised at how often a reboot fixes many mosquitto problems.

um... no!

check the mosquitto log.  if necessary, restart the mostquitto process.  or turn up the logging level in mosquitto.

reboot is what you do if you cannot be bothered to actually fix the problem.  its putting black tape over the "out of oil" indicator in your car, then wondering why, one day, your car won't ever start again.

Pat

unread,
Jun 15, 2019, 3:38:39 PM6/15/19
to weewx-user
Thanks mwall. Might explain why I go through cars every 3,000 miles :) 

It seems that mosquitto version 1.4.15 is more forgiving with the configs. I just tried to break it with known whitespace problems and it started without issue. So check the mosquitto.log to see what's wrong.
Reply all
Reply to author
Forward
0 new messages