pubsubclient
pubsubclient copied to clipboard
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Hi,
I am experiencing some kernel panics when using the pubsubclient library. The code is quite straightfoward, just connect to an active wifi client. I have attached a simplifed version below. The issue only happens when de ESP it's not capable of connect to the MQTT server (when the IP is wrong and it's being refused). Any suggestions what might be happening. I am wondering that maybe a memory issue somehow but I don't know how to go deeper into it.
pubsubclient: 2.8.0
static WiFiClient _wifiClient;
static PubSubClient _mqttClient(_wifiClient);
_mqttClient.setServer(addr, port);
while (!_mqttClient.connected())
{
if ( _mqttClient.connect("SomeID")) <----- Here it breaks
{
Serial.println("MQTT connected");
// Once connected, publish an announcement...
_mqttClient.publish(_topic, String(clientId + " connected").c_str());
}
else
{
Serial.printf("MQTT failed, state %s, retrying...\n", _mqttClient.state());
// Wait before retrying
delay(2500);
}
}
}
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400014e8 PS : 0x00060830 A0 : 0x80103a64 A1 : 0x3ffb1a40
A2 : 0xfffffffe A3 : 0xfffffffc A4 : 0x000000ff A5 : 0x0000ff00
A6 : 0x00ff0000 A7 : 0xff000000 A8 : 0x462d4100 A9 : 0x3ffb1da0
A10 : 0x00000000 A11 : 0x00000036 A12 : 0x00001007 A13 : 0x3ffb1de4
A14 : 0x3ffb1de8 A15 : 0x3ffc3a68 SAR : 0x0000000a EXCCAUSE: 0x0000001c
EXCVADDR: 0xfffffffc LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff
Backtrace: 0x400014e8:0x3ffb1a40 0x40103a61:0x3ffb1a50 0x4010afda:0x3ffb1d60 0x4010b016:0x3ffb1df0 0x400d5c7a:0x3ffb1e30 0x400d12e9:0x3ffb1ed0 0x400d13bb:0x3ffb1f30 0x400d1605:0x3ffb1f70 0x400d6343:0x3ffb1fb0 0x4008930d:0x3ffb1fd0
That after appliying the exception decoder results in:
PC: 0x400014e8
EXCVADDR: 0xfffffffc
Decoding stack results
0x40103a61: _svfprintf_r at ../../../.././newlib/libc/stdio/vfprintf.c line 1529
0x4010afda: _vsnprintf_r at ../../../.././newlib/libc/stdio/vsnprintf.c line 72
0x4010b016: vsnprintf at ../../../.././newlib/libc/stdio/vsnprintf.c line 41
0x400d5c7a: Print::printf(char const*, ...) at C:\Users\user\AppData\Local\Arduino15\packages\Heltec-esp32\hardware\esp32\0.0.5\cores\esp32\Print.cpp line 55
0x400d12e9: connectMQTT() at C:\Users\user\Desktop\LoraGateway\LoRaGateway/MQTT.ino line 70
0x400d13bb: connectToMQTTServer(IPAddress, unsigned short) at C:\Users\user\Desktop\LoraGateway\LoRaGateway/MQTT.ino line 38
0x400d1605: setup() at C:\Users\user\Desktop\LoraGateway\LoRaGateway/LoRaGateway.ino line 89
0x400d6343: loopTask(void*) at C:\Users\user\AppData\Local\Arduino15\packages\Heltec-esp32\hardware\esp32\0.0.5\cores\esp32\main.cpp line 14
0x4008930d: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
Cheers
Same Issue
I've been seeing random panics on an ESP32 as well. Running PubSubClient and MQTT to Watson IoT Platform. It will run for many hours or just a few minutes. Then panic. The ESP32 is silently looping, reading an accelerometer once a second, checking its still mqtt.connected(), if there's a shake, start transmitting over MQTT. Can't lay blame on PubSubClient or connection stability just yet...
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
Same Issue calling connect function
My ESP32 was panicking because of a faulty PCB board that was causing random brown outs. It wasn't an issue with PubSubClient or MQTT
I was testing and a simple code just works, but in my project i need the conection to be in a class, the simple class below causes the panic in the constructor:
Class Definition
#include <Arduino.h>
#include <PubSubClient.h>
#include <WiFi.h>
class MqttClient : public PubSubClient {
private:
// WiFi
const char *ssid = "";
const char *pass = "";
void connectWifi();
// MQTT
const char * broker_ip = "";
const char * broker_user = "";
const char * broker_pass = "";
const char *my_id = "";
public:
MqttClient();
~MqttClient();
};
Class Implementation
#include "mqtt_client.h"
MqttClient::MqttClient() {
Serial.println("Construindo Cliente");
PubSubClient(my_id, 1883, *(new WiFiClient()));
connectWifi();
Serial.println("Vou conectar ao broker");
connect(my_id, broker_user, broker_pass);
if(connected()) {
Serial.println("Conectado");
}else {
Serial.println("Falha ao conectar");
}
}
void MqttClient::connectWifi() {
WiFi.begin(ssid, pass);
unsigned long time_lim = millis() + 10000;
while ((WiFi.status() != WL_CONNECTED) && (millis() < time_lim)) {
Serial.print(".");
delay(500);
}
if (WiFi.status() != WL_CONNECTED) {
delay(100);
ESP.restart();
}
Serial.println("\nConectado");
WiFi.mode(WIFI_STA);
}
MqttClient::~MqttClient() {
Serial.println("Destruindo Cliente");
}
is there any specific way to initialize the PubSubClient object? Or another issue explaining how to to this?
Sorry if I wrote something wrong, and appreciate any help
The issue only happens when de ESP it's not capable of connect to the MQTT server (when the IP is wrong and it's being refused). Any suggestions what might be happening. I am wondering that maybe a memory issue somehow but I don't know how to go deeper into it.
I am having the same behavior. Were you able to resolve this?
I had this same issue. I solved it by making the WiFiClient variable global. -Damian
Same issue with ESP32 TTGO LilyGO by implementing Smart-Watch with GPS, pulse-oximeter, and web-frontend. The fun fact is - I downgraded to a (more simple) alpha version of code and the thing is working! Might be we are overcomplicating tasks for this chip! If someone has issue solved, notice me!
No Solution Up till now ?
same issue in 2023 :(
Still same issue @ 22 mei 2023
Still same issue @ 22 mei 2023
I fixed the issue, I was using FreeRTOS, I stopped using it for a specific library and it got fixed.
But I don't know the reason why it got fixed. Not very helpful information I know.
Converted tensor flow model tflite micro for specch recognition (yes, no).
After loaded the .cc buffer into ESP, start giving an error " Bad input tensor parameters in model Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled "
i also have similar problems which when successfully connected to the broker it crashed. `odem Info: SIM800 R14.18 Waiting for network...[33538] ### Network time and time zone updated. [33538] ### Daylight savings time state updated. success Network connected Connecting to Internet success GPRS connected === MQTT NOT CONNECTED === Connecting to myMQTTBROKER success Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x40086585 PS : 0x00060a30 A0 : 0x800d68b6 A1 : 0x3ffb2200
A2 : 0x00000000 A3 : 0xfffffffc A4 : 0x000000ff A5 : 0x0000ff00
A6 : 0x00ff0000 A7 : 0xff000000 A8 : 0x00000000 A9 : 0x3ffb21b0
A10 : 0x0000bbe1 A11 : 0x3ffc2663 A12 : 0x00000025 A13 : 0xffffff80
A14 : 0x3ffb21dc A15 : 0xff000000 SAR : 0x0000000a EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x40086585 LEND : 0x40086595 LCOUNT : 0xffffffff
Backtrace: 0x40086582:0x3ffb2200 0x400d68b3:0x3ffb2210 0x400d6919:0x3ffb2230 0x400d2aed:0x3ffb2250 0x400d4859:0x3ffb2270 0x400da805:0x3ffb2290
#0 0x40086582:0x3ffb2200 in strlen at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/strlen.S:82 #1 0x400d68b3:0x3ffb2210 in PubSubClient::subscribe(char const*, unsigned char) at .pio/libdeps/esp32doit-devkit-v1/PubSubClient/src/PubSubClient.cpp:476 #2 0x400d6919:0x3ffb2230 in PubSubClient::subscribe(char const*) at .pio/libdeps/esp32doit-devkit-v1/PubSubClient/src/PubSubClient.cpp:469 #3 0x400d2aed:0x3ffb2250 in mqttConnect() at src/main.cpp:194 #4 0x400d4859:0x3ffb2270 in loop() at src/main.cpp:313 #5 0x400da805:0x3ffb2290 in loopTask(void*) at C:/Users/Asus/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:50
ELF file SHA256: ffa890917d9d8167`
i hope someone can solve this issue
Hello everyone :wave:
Same issue here , but more precisely when the MQTT Server (EMQX) denies the connection attempt because the previous connection have not yet timeout from the broker (Keepalive) and the broker don't allow existing client id to join.
Log Trace
[MQTT] Reconnecting
[ 7263][V][ssl_client.cpp:62] start_ssl_client(): Free internal heap before TLS 206676
[ 7264][V][ssl_client.cpp:68] start_ssl_client(): Starting socket
[ 7275][V][ssl_client.cpp:146] start_ssl_client(): Seeding the random number generator
[ 7277][V][ssl_client.cpp:155] start_ssl_client(): Setting up the SSL/TLS structure...
[ 7282][V][ssl_client.cpp:178] start_ssl_client(): Loading CA cert
[ 7294][V][ssl_client.cpp:254] start_ssl_client(): Setting hostname for TLS session...
[ 7296][V][ssl_client.cpp:269] start_ssl_client(): Performing the SSL/TLS handshake...
[ 8587][V][ssl_client.cpp:290] start_ssl_client(): Verifying peer X.509 certificate...
[ 8587][V][ssl_client.cpp:298] start_ssl_client(): Certificate verified.
[ 8591][V][ssl_client.cpp:313] start_ssl_client(): Free internal heap after TLS 165028
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x40089c98 PS : 0x00060530 A0 : 0x800dc3f1 A1 : 0x3ffcc2d0
A2 : 0x932af3f0 A3 : 0x932afbf0 A4 : 0x3ffd8df8 A5 : 0x0000000f
A6 : 0x00ff0000 A7 : 0xff000000 A8 : 0x932af3f0 A9 : 0x3ffd8df7
A10 : 0x00000000 A11 : 0x3f405e44 A12 : 0x000022b3 A13 : 0x3f40153c
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x00000019 EXCCAUSE: 0x0000001c
EXCVADDR: 0x932af3f0 LBEG : 0x40089ab1 LEND : 0x40089ac1 LCOUNT : 0xfffffffb
Backtrace: 0x40089c95:0x3ffcc2d0 0x400dc3ee:0x3ffcc2f0 0x400dc569:0x3ffcc330 0x400dfb7b:0x3ffcc360 0x400dfbba:0x3ffcc390 0x400d3ad2:0x3ffcc3b0 0x400e5609:0x3ffcc3d0
I have similar issue while using esp32.
Core 1 register dump:
PC : 0x400d2e16 PS : 0x00060d30 A0 : 0x800d7805 A1 : 0x3ffd00d0
A2 : 0x00000000 A3 : 0x3ffc4028 A4 : 0x00000002 A5 : 0x3ffc4170
A6 : 0x3f40027a A7 : 0x80000001 A8 : 0x800d2e08 A9 : 0x3ffd0000 ```
Does it depend on memory used on that board? (the board said 61% of memory used).
**update : this error occur while connecting wifi.**
I had also core panic... i fixed it with an if
//set eth status ( i use ENC28J60 and it works)
if (Ethernet.linkStatus() == Unknown) {
strcpy(lnkStatus, "ETH_LNK_9");
} else if (Ethernet.linkStatus() == LinkON) {
strcpy(lnkStatus, "ETH_LNK_1");
} else if (Ethernet.linkStatus() == LinkOFF) {
strcpy(lnkStatus, "ETH_LNK_0");
}
}
//calling function
void mqttPublish(String device, String message) {
setEthStatus();
if (strcmp(lnkStatus, "ETH_LNK_1") == 0) {
if (mqttClient.connect(DEVICE_NAME)) {
//mqttClient.publish(SLAVE_NAME_PATTERN+device, message);
mqttClient.publish("test/topic", "lololol");
mqttClient.disconnect();
}
}
}```
Same problem for me, that works for me
WiFiClient espClient;
PubSubClient client(espClient);
I just forget or miss this setup.