Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with dynamic update / MQTT #957

Open
thefl0yd opened this issue Oct 27, 2024 · 3 comments · May be fixed by #975
Open

Issues with dynamic update / MQTT #957

thefl0yd opened this issue Oct 27, 2024 · 3 comments · May be fixed by #975
Labels
bug Something isn't working

Comments

@thefl0yd
Copy link

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
Websockets implementation seems to have quit working.

I migrated to a new install. Fresh weewx 5.1 install, weewx-belchertown install from the current git (latest release did not work due to python locale.format_string changes). Connection flashes between:

Connected. Waiting for data. Last Updated October 27, 2024, 10:55:00 AM
and 'Lost connection ...' (can't copy the whole thing as it flashes too quickly before reconnecting and flashing the first message)

The first timestamp is my most recent archive, and it seems to flash 'lost connection' every time a loop packet arrives.

I have validated that I can connect to the mqtt broker and see the loop packets. Mosquitto logs the web app connecting and disconnecting repeatedly.

The formerly working MQTT implementation has not been changed. The issue appears to be localized to weewx/belchertown skin.

Link to your website (IMPORTANT)
https://www.insomnia.org/wxdata

Version of the skin you're using
Latest from git

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
Dynamic updates via MQTT

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

Device Information (please complete the following information):

  • Device: [e.g. desktop, iPhone6]
  • OS: [e.g. Windows, Android, iOS]
  • Browser [e.g. Chrome, Safari]
  • Version [e.g. 22]

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!

@thefl0yd thefl0yd added the bug Something isn't working label Oct 27, 2024
@thefl0yd
Copy link
Author

thefl0yd commented Nov 1, 2024

further testing here seems to confirm that the loop packets are what force the disconnect. If the server-side weewxd is either not running or not sending loop packets to my MQTT the website just shows connected/waiting for updates perpetually. Once the regular loop packets come in, the web app gets disconnected and reconnects every time a loop packet arrives. The skin does not ever work as expected.

@thefl0yd
Copy link
Author

thefl0yd commented Nov 2, 2024

finally was able to debug this further:

[Log] MQTT: MQTT Connected. Subscribing. (belchertown.js, line 40)
[Log] MQTT: {"dateTime": "1730507447.0", "usUnits": "1.0", "maxSolarRad_Wpm2": "0.0", "rainRate_inch_per_hour": "0.0", "hourRain_in": "0.0", "rain24_in": "0.0", "dayRain_in": "0.0", "rainSize_in": "0.01", "rainCountRate_per_hour": "0.0", "windDir": "17.0", "windSpeed_mph": "8.0", "windGust_mph": "8.5", "windGustDir": "11.0", "rainCount_count": "0.0", "rain_in": "0.0"} (belchertown.js, line 40)
[Log] MQTT: 2024-11-01T20:30:48-04:00: mqtt Connection Lost: AMQJS0005E Internal error. Error Message: invalid language tag: C, Stack trace: No Error Stack Available (belchertown.js, line 866)
[Log] MQTT: MQTT Connected. Subscribing. (belchertown.js, line 40)

Not sure where to look next though. Does anyone have a suggestion?

@refactoringdr
Copy link

I figured out that the MQTT server was sending an "offline" message that was borking the JSON parse. It also is a "retain" message, so it's always there. I added catch to just eat the bad parses in onMessageArrived. Here's the code:

// New message from mqtt, process it
function onMessageArrived(message) {
    belchertown_debug("MQTT: " + message.payloadString);
    try {
        update_current_wx(message.payloadString);
    } catch(e) {
        return
    }
    mqtt_payload = jQuery.parseJSON(message.payloadString);
}```

Seems to fix the problem. Thanks for a great skin!

@uajqq uajqq linked a pull request Jan 14, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants