Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

guru mediation error when you cannot connect to broker #1063

Open
Tntceria opened this issue Jul 12, 2024 · 0 comments
Open

guru mediation error when you cannot connect to broker #1063

Tntceria opened this issue Jul 12, 2024 · 0 comments

Comments

@Tntceria
Copy link

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);
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant