fixed emqx HA issue when aliyun connecting fails

This commit is contained in:
strawmanbobi
2025-01-03 09:42:38 +08:00
parent adf7f61e7d
commit 92f1af2656
3 changed files with 10 additions and 7 deletions

View File

@@ -118,6 +118,7 @@ static void callback(char *topic, byte *payload, unsigned int length) {
}
static bool mqttConnecting = false;
int AliyunIoTSDK::mqttCheckConnect() {
int mqttStatus = 0;
int connectRetry = 0;
@@ -146,11 +147,11 @@ int AliyunIoTSDK::mqttCheckConnect() {
Serial.println(client->state());
delay(MQTT_WAIT_GENERIC);
connectRetry++;
Serial.print("INFO:\tretry: ");
Serial.print("INFO:\tAliot connection retry: ");
Serial.println(connectRetry);
mqttStatus = -1;
if (connectRetry > MQTT_CONNECT_RETRY_MAX) {
Serial.println("ERROR:\t max connect retry times reached");
Serial.println("ERROR:\tMax connect retry times reached");
break;
}
}
@@ -204,7 +205,7 @@ int AliyunIoTSDK::begin(PubSubClient &mqtt_client,
#if defined USE_STANDARD_THING_MODEL_TOPIC
client.setCallback(callback);
#endif
Serial.print("INFO\tconnection check in begin\n");
Serial.print("INFO\tConnection check in begin\n");
return mqttCheckConnect();
}