poblabs/weewx-belchertown

MQTT publish not working

Closed this issue · 7 comments

Please don't delete these questions! They are asked almost with every issue - answering them as below saves us time from asking them!

First step
Try to debug the skin yourself. If you can't figure it out, please include the debug information (text, screenshots, etc.). See this guide on debugging the skin. https://github.com/poblabs/weewx-belchertown#how-to-use-debug

Describe the bug
A clear and concise description of what the bug is.

  1. broker is mosquitto on Digital Ocean droplet
  2. SSL in place
  3. Web clients show connected but always waiting for data.
  4. mosquitto logging shows webclients subscribing
  5. no publish lines in mosquitto logs (logging set to all)
  6. publishing from command line works and I can see that it goes to client because the connected waiting.. flashes. Of course I am not sending real data from command line so doesnt update anything
  7. I can telnet from the weewx server to mqtt broker on 8883

In syslog on weewx I see:
Aug 23 16:07:31 raspberrypi weewx[14709] ERROR weewx.restx: MQTT: Failed to publish record 2021-08-23 16:07:16 MDT (1629756436): Failed upload after 3 tries
Aug 23 16:07:46 raspberrypi weewx[14709] ERROR weewx.restx: MQTT: Failed to publish record 2021-08-23 16:07:19 MDT (1629756439): Failed upload after 3 tries

From skin.conf

MQTT Websockets defaults

mqtt_websockets_enabled = 1
mqtt_websockets_host = "weather2.sangrephotography.com"
mqtt_websockets_port = 9001
mqtt_websockets_ssl = 1
mqtt_websockets_topic = "weather/loop"
disconnect_live_website_visitor = 1800000

And from weewx.conf
[[MQTT]]
server_url = mqtt://xxxxx:xxxxx@weather2.sangrephotography.com:8883/
topic = weather
unit_system = US
binding = archive,loop
aggregation=aggregate
log_failure =true
log_success = true
[[[tls]]]
# CA certificates file (mandatory)
ca_certs = /etc/ssl/certs/ca-certificates.crt
# PEM encoded client certificate file (optional)
certfile = /etc/ssl/certs/cert2.pem
# private key file (optional)
keyfile = .etc/ssl/certs/privkey2.pemy
# Certificate requirements imposed on the broker (optional).
# Options are 'none', 'optional' or 'required'.
# Default is 'required'.
cert_reqs = required
# SSL/TLS protocol (optional).
# Options include sslv1, sslv2, sslv23, tls, tlsv1, tlsv12
# Default is 'tlsv1'
# Not all options are supported by all systems.
tls_version = tlsv1
# Allowable encryption ciphers (optional).
# To specify multiple cyphers, delimit with commas and enclose
# in quotes.
#ciphers =

Link to your website (IMPORTANT)
https://weather.sangrephotography.com
broker at weather2.sangrephotography.com

Version of the skin you're using
1.2

To Reproduce
Steps to reproduce the behavior:
Behavior is client always waiting for data

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Device Information (please complete the following information):
not a client issue. Same status on phone, Edge, Safari, Chrome

Additional context
Add any other context about the problem here. Maybe a potential fix?

HELP WANTED
If you have a fix for this, please submit a pull request against the development branch!

Have you tried without a username and password? This will require you to reconfigure your mqtt broker

I have modified broker to allow anonymous. no change in behavoior. I have also tried insecure which doesn't help either.

Have you used a desktop client to try to publish? Have you rebooted the server or matt service?

If weeqx mqtt extension says it failed to publish then something is wrong at the broker side.

2021-08-23T19:14:42.457] [INFO] default - APP init
[2021-08-23T19:18:11.890] [INFO] default - Connect client, MQTT/SSL connection: mqtts://weather2.sangrephotography.com:8883
[2021-08-23T19:18:11.893] [INFO] default - MQTTX client with ID d3bf7d39-5164-4a6f-a64c-4b9002045483 assigned
[2021-08-23T19:18:13.462] [INFO] default - Connect success, MQTT.js onConnect trigger
[2021-08-23T19:18:42.414] [INFO] default - Sucessfully published message "{\n "msg": "hello"\n}" to topic "test"

I changed my url in weewx.conf to use mqtts instead of mqtt but that didnt' help. the above code was generated using mqttx. So it appears the broker is working

So I'm able to connect to your broker on mqtt and websockets and everything seems fine.

You still have an issue somewhere between weewx and your broker - so this isn't Belchertown skin related right now.

I'm not sure what else I can help with. Maybe paste your mosquitto config?

I have a write up on how to setup mqtt here: https://obrienlabs.net/how-to-setup-your-own-mqtt-broker/

Maybe start over and follow those instructions?

Or from your weewx machine, use the mosquitto_pub command listed in that write up to make sure the 2 machines can "talk" to each other?

Check your firewall settings?

Thanks for testing. It wasn't on broker end. I follow the instructions in your link initially. I am consfused as to how I would have mosquitto_pub on my weewx machine. It doesn't have mosquitto installed. In any evernt the good new is I have it working in insecure mode and I am really not concerned about that data being intercepted. I must have some bug in my [[TLS]] configuration but for now I can just use 1883. Thanks for all your help and for providing such a beautiful skin.

It's working for me too! Glad you're all setup now.