Skip to content

Commit ece2c14

Browse files
authored
Merge pull request #14 from myDevicesIoT/hotfix/esp8266-reconnect
Reconnect if ping fails.
2 parents ea72b34 + 78ef392 commit ece2c14

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/CayenneMQTTClient/MQTTClient.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ int keepalive(MQTTClient* c)
228228
TimerCountdown(&c->ping_response_timer, c->keepAliveInterval);
229229
c->ping_outstanding = 1;
230230
}
231+
else if (rc == MQTT_FAILURE && TimerIsExpired(&c->last_received_timer))
232+
{
233+
//If the ping packet failed and the last received timer has expired assume we are disconnected
234+
c->isconnected = 0;
235+
}
231236
}
232237
else if (TimerIsExpired(&c->ping_response_timer))
233238
{

0 commit comments

Comments
 (0)