eclipse-paho / paho.mqtt.golang

Other
2.77k stars 534 forks source link

ESP8266 disconnects from AWS IoT on new message #587

Closed audreylim closed 2 years ago

audreylim commented 2 years ago

ESP8266 Client disconnects and reconnects when new message is published to topic on AWS IoT:

Retain: true qos: 0

ESP8266 logs:

PubSubClient connecting to: {aws_endpoint}
Message received on topic_1: hello
PubSubClient connecting to: {aws_endpoint}
Message received on topic_1: hello2

Code:

void loop() {
  pubSubCheckConnect();
}

boolean reconnect() {
  if (pubSubClient.connect("clientID")) {
    Serial.println(" connected!!!");
    pubSubClient.subscribe("topic_1");
  }
  return pubSubClient.connected();
}

void pubSubCheckConnect() {
  if (!pubSubClient.connected()) {
     Serial.print("PubSubClient connecting to: "); Serial.print(awsEndpoint);
    long now = millis();
    if ((now - lastReconnectAttempt) > 500) {
      lastReconnectAttempt = now;
      if (reconnect()) {
        Serial.print("reconnect");
        lastReconnectAttempt = 0;
      }
    }
  } else {
    pubSubClient.subscribe("topic_1");
  }

  pubSubClient.loop();
}

Hoping to find out what's causing the disconnect to avoid the random soft WDT reset problem:

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Soft WDT reset

>>>stack>>>

ctx: bearssl
sp: 3fff0088 end: 3fff0f
MattBrittan commented 2 years ago

You have raised this issue in eclipse/paho.mqtt.golang which is for the Paho MQTT client written in Go; the source you have shared looks like C (so not Go)... Perhaps you meant to raise this here?

I'm closing this for now because the question does not appear to be relevant to this repository. If you believe this is incorrect then please edit the question and explain how this relates to the Go client.

audreylim commented 2 years ago

Correct, oops sorry!