You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If my esp32 cannot connect to a broker or if the broker is down I keep getting a guru mediation error causing the esp32 to restart, this ends up draining the battery on my IOT device. Below is the section of code that causes the error, I never see the message "MQTT failed"
// connect to MQTT server
void connectMQTT() {
// Wait until we're connected
while (!client.connected()) {
// Create a random client ID
String clientId = "ESP32-";
clientId += String(random(0xffff), HEX);
Serial.printf("MQTT connecting as client %s...\n", clientId.c_str());
// Attempt to connect
if (client.connect(clientId.c_str(),mqtt_username,mqtt_password)) {
Serial.println("MQTT connected");
// Once connected, publish an announcement...
client.publish(topic, "hello from ESP32");
// ... and resubscribe
client.subscribe(topic);
} else {
Serial.printf("MQTT failed, state %s, retrying...\n", client.state());
// Wait before retrying
delay(2500);
}
}
}
The text was updated successfully, but these errors were encountered:
If my esp32 cannot connect to a broker or if the broker is down I keep getting a guru mediation error causing the esp32 to restart, this ends up draining the battery on my IOT device. Below is the section of code that causes the error, I never see the message "MQTT failed"
// connect to MQTT server
void connectMQTT() {
// Wait until we're connected
while (!client.connected()) {
// Create a random client ID
String clientId = "ESP32-";
clientId += String(random(0xffff), HEX);
Serial.printf("MQTT connecting as client %s...\n", clientId.c_str());
// Attempt to connect
if (client.connect(clientId.c_str(),mqtt_username,mqtt_password)) {
Serial.println("MQTT connected");
// Once connected, publish an announcement...
client.publish(topic, "hello from ESP32");
// ... and resubscribe
client.subscribe(topic);
} else {
Serial.printf("MQTT failed, state %s, retrying...\n", client.state());
// Wait before retrying
delay(2500);
}
}
}
The text was updated successfully, but these errors were encountered: