stuartpittaway / diyBMSv4ESP32

diyBMS v4 code for the ESP32 and new controller hardware
Other
179 stars 80 forks source link

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

Open HerrFrodo1 opened 1 year ago

HerrFrodo1 commented 1 year ago

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 commented 1 year ago

Additional information:

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

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

HerrFrodo1 commented 1 year ago

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

stuartpittaway commented 1 year ago

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

HerrFrodo1 commented 1 year ago

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.

stuartpittaway commented 1 year ago

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 commented 1 year ago

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