esphome / esphome/issues

MQTT-IDF fails to initialise (memory exhausted)

Open
#5,774 1 comment 1 reaction 0 assignees View on GitHub
stale
Dominant language
No language data
Stars
313
Forks
40
PR merge metrics
No merged PRs in 30d

Description

### The problem

A configuration file that used to work with an older version of ESPHome (2022.6.3) now fails to initialise the MQTT client. From the logs it seems that some memory is exhausted, even though there should be plenty of memory.

### Which version of ESPHome has the issue?

2024.4.2

### What type of installation are you using?

pip

### Which version of Home Assistant has the issue?

N/A

### What platform are you using?

ESP32

### Board

heltec_wifi_kit_32_v2 (8MB flash)

### Component causing the issue

mqtt

### Example YAML snippet

_No response_

### Anything in the logs that might be useful for us?

```txt
[20:42:11][C][mqtt:037]: Setting up MQTT...
[20:42:11][W][component:157]: Component mqtt set Warning flag: unspecified
[20:42:11][I][mqtt:234]: Connecting to MQTT...
[20:42:11][D][esp-idf:000]: E (9006) MQTT_CLIENT: esp_mqtt_client_init(795): Memory exhausted
[20:42:11]
[20:42:11][E][mqtt.idf:103]: Failed to initialize IDF-MQTT
[20:42:11][W][component:170]: Component wifi cleared Warning flag
[20:42:11][D][sntp:080]: Synchronized time: 2024-05-08 20:42:11
```

```txt
09:50:52][C][mqtt:037]: Setting up MQTT...
[09:50:52][W][component:157]: Component mqtt set Warning flag: unspecified
[09:50:52][I][mqtt:234]: Connecting to MQTT...
[09:50:52][D][esp-idf:000]: E (9947) esp-tls: couldn't get hostname for :192.168.178.40: getaddrinfo() returns 203, addrinfo=0x0
[09:50:52]
[09:50:52][D][esp-idf:000]: E (20418) TRANSPORT_BASE: Failed to open a new connection: 32769
[09:50:52]
[09:50:52][D][esp-idf:000]: E (20419) MQTT_CLIENT: Error transport connect
[09:50:52]
[09:50:52][D][esp-idf:000]: E (20642) MDNS: Cannot allocate memory (line: 4591, free heap: 200 bytes)
[09:50:52]
[09:50:53]
[09:50:53]abort() was called at PC 0x4021bb23 on core 1
```

### Additional information

Looking at the compile output there should be plenty of memory:
Compiling .pioenvs/co2-sensor/src/main.cpp.o
Linking .pioenvs/co2-sensor/firmware.elf
RAM: [== ] 18.1% (used 59280 bytes from 327680 bytes)
Flash: [===== ] 50.0% (used 1965853 bytes from 3932160 bytes)
Building .pioenvs/co2-sensor/firmware.bin

However, I am using, the web server, BLE server (github://wifwucite/esphome-ble-controller) and MQTT. So some internal buffer seems to overrun. But with the Arduino framework based MQTT client, things used to work fine.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.