-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
My platform is NodeMCU 1.0 (ESP-12E)
I read similar posts here and there concluding on FastLED or other library issues, but I am not using these libraries.
Almost 60% of the time the connection attempt is causing a Soft WDT reset as the connection attempt is blocking too long and apparently I have no control over it., setting the socket timeout to 1 sec also doesn't help.
There is obviously a slight chance that something else is causing the issue, but I doubt it since I always have the watchdog issue appearing when MQTT tries connecting. Please let me know how to find out if something else is blocking ?
I also tried adding below in vain:
mqtt_client.setSocketTimeout(1);The neuralgic code part:
#define MQTT_SOCKET_TIMEOUT 1
// ...
bool mqtt_connected = false;
while (!mqtt_client.connected() && retries < 10)
{
time_t now = time(NULL);
SerialPrint("-> MQTT connecting ... ");
// PubSubClient::connect(const char *id, const char *user, const char *pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage, boolean cleanSession
if (!CleanSession) mqtt_connected = mqtt_client.connect(mqtt_client_id, mqtt_username, sas_token, 0, 0, 0, 0, 0);
else mqtt_connected = mqtt_client.connect(mqtt_client_id, mqtt_username, sas_token);
if (mqtt_connected)
{
char connMsg[60];
snprintf(connMsg, sizeof(connMsg), "connected in %d ms", millis() - connectStart);
SerialPrintln(connMsg);
}
else
{
int c = mqtt_client.state();
char errMsg[64];
if (c == MQTT_CONNECTION_TIMEOUT) snprintf(errMsg, sizeof(errMsg), " connection timeout, status code = %d", c);
if (c == MQTT_CONNECTION_LOST) snprintf(errMsg, sizeof(errMsg), " connection lost, status code = %d", c);
if (c == MQTT_CONNECT_FAILED) snprintf(errMsg, sizeof(errMsg), " connection failed, status code = %d", c);
if (c == MQTT_DISCONNECTED) snprintf(errMsg, sizeof(errMsg), " disconnected, status code = %d", c);
if (c == MQTT_CONNECT_BAD_PROTOCOL) snprintf(errMsg, sizeof(errMsg), " bad protocol, status code = %d", c);
if (c == MQTT_CONNECT_BAD_CLIENT_ID) snprintf(errMsg, sizeof(errMsg), " bad client id, status code = %d", c);
if (c == MQTT_CONNECT_UNAVAILABLE) snprintf(errMsg, sizeof(errMsg), " unavailable, status code = %d", c);
if (c == MQTT_CONNECT_BAD_CREDENTIALS) snprintf(errMsg, sizeof(errMsg), " bad credentials, status code = %d", c);
if (c == MQTT_CONNECT_UNAUTHORIZED) snprintf(errMsg, sizeof(errMsg), " unauthorized, status code = %d", c);
SerialPrint(errMsg);
char sslErr[100];
if (wifi_client.getLastSSLError(sslErr, 100) < 0)
{
char sslMsg[128];
snprintf(sslMsg, sizeof(sslMsg), " , SSL error : %s", sslErr);
SerialPrintln(sslMsg);
}
else SerialPrintln();
SerialPrintln();
SerialPrintln("-> Retrying MQTT connection in 3 seconds...");
delay(3000);
}
retries++;
}`
Debug print:
-> MQTT connecting ...
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Soft WDT reset
Metadata
Metadata
Assignees
Labels
No labels