hirotakaster / MQTT

MQTT for Photon, Spark Core
Other
216 stars 118 forks source link

Disconnects on Particle Core #69

Closed natcl closed 3 years ago

natcl commented 6 years ago

With the mqtttest example, I cannot get a stable connexion on the Particle Core. I tried with a remote broker and a local one with the same results. After a few hours it stops responding and on the broker side I get a Socket Error from the client. Any ideas what could be causing this ?

natcl commented 6 years ago

Update: Seems to be related to the connection keepalive, here's what I get on my broker:

client core-client has exceeded timeout, disconnecting
Socket error on client core-client

In my loop I have this code which I assume should reconnect:

void loop() {
    if (client.isConnected()) {
        client.loop();
    } else {
        delay(1000);
        client.connect("mf-core-client");
        init(); // init handles the subscribes
    }

}
hirotakaster commented 6 years ago

@natcl Thank you for your report. I think your code is good. client and server tcp connection is disconnected by several TCP's protocol causes, so your reconnect implementation will good for.