diyBMSv4ESP32 icon indicating copy to clipboard operation
diyBMSv4ESP32 copied to clipboard

After planned WLAN night shutdown MQTT has no data flow after reconnecting to access point

Open HerrFrodo1 opened this issue 2 years ago • 6 comments
trafficstars

To protect my small children from WLAN radiation, I automatically switch off the WLAN at night. At 6:30am WiFi turns on again. Sometimes the diyBMS could not be reached via the web server - but I have to test that more closely. However, MQTT no longer works in connection with IOBroker. In the IOBroker instances the connection is ok but no data is updated. Like frozen. The CAN bus transmission to the Victron Cerbo GX works permanently. Unfortunately, I then have to restart the diyBMS - which always leads to a power failure in my island system.

Hardware/Software Versions Controller version (from PCB): 4.5

Version: https://github.com/stuartpittaway/diyBMSv4ESP32/commit/7780f30b8fd333e90c7ba5f930b68b447d958c9f

Compiled: 2023-02-21T08:54:23.262Z

To Reproduce Steps to reproduce the behavior:

  1. Shut down WLAN connection (for few hours)
  2. Activate WLAN
  3. Check your diyBMS Webserver and check MQTT Data in IOBroker VIS

HerrFrodo1 avatar Mar 16 '23 16:03 HerrFrodo1

Additional information:

Router: Fritz!Box 7490 1GBit LAN Bridge to Fritz!Repeater 300E

WLAN shutdown @ 23:00, activate @ 6:30am.

HerrFrodo1 avatar Mar 17 '23 08:03 HerrFrodo1

Today the Webserver is not reachable. Later @ home I check with PuTTy for messages.

HerrFrodo1 avatar Mar 17 '23 08:03 HerrFrodo1

You've previously mentioned that if you power off the router/wifi AP point and reboot DIYBMS connections successfully - does that include MQTT activity?

stuartpittaway avatar Mar 17 '23 11:03 stuartpittaway

Maybe I didn't understand you correctly - if I turn off the AP, then I don't restart the connection of the diyBMS. Only after the AP is online the web server is mostly unavailable and MQTT always doesn't work.

I sent you a link for PuTTy Screen capture on Patreon.

HerrFrodo1 avatar Mar 17 '23 13:03 HerrFrodo1

Thanks for the screen video capture.

These are the events I've recorded out of that. It looks like the MQTT client doesn't clean up memory properly when the wifi goes down.

MQTT_EVENT_DISCONNECTED
MQTT ENABLED, BUT WIFI NOT CONNECTED
STOPPING MQTT CLIENT
CONNECT MQTT - HOST IS UNREACHABLE
TRANSPORT_BASE: Failed to open a new connection
MQTT_CLIENT Error transport connect
MQTT_EVENT_ERROR
MQTT_EVENT_DISCONNECTED

Retry 16: connect to WiFi AP
Retry 21: connect to WiFi AP
Retry 24: connect to WiFi AP
Retry 27: connect to WiFi AP
Got IP: 192.168.1.X
Stopping MQTT
esp_err_t - line 94 ESP_FAIL
ESP_ERR_INVALID_ARG @ MQTT.CPP line 95
esp_mqtt_client_destroy

**esp_mqtt_client_init - memory exhausted**

MQTT enabled, but not connected to broker

stuartpittaway avatar Mar 17 '23 14:03 stuartpittaway

This looks like its related to.. https://github.com/espressif/esp-idf/issues/5668

stuartpittaway avatar Mar 17 '23 14:03 stuartpittaway