Skip to content

Commit

Permalink
Merge pull request #7 from damdo/fix-keepalive
Browse files Browse the repository at this point in the history
fix: keepalive behviour when set to 0
  • Loading branch information
imbeacon authored Apr 4, 2024
2 parents e6cac2f + d471121 commit 30880ad
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/PubSubClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ uint32_t PubSubClient::readPacket(uint8_t* lengthLength) {
boolean PubSubClient::loop() {
if (connected()) {
unsigned long t = millis();
if ((t - lastInActivity > this->keepAlive*1000UL) || (t - lastOutActivity > this->keepAlive*1000UL)) {
if (((t - lastInActivity > this->keepAlive*1000UL) || (t - lastOutActivity > this->keepAlive*1000UL)) && keepAlive != 0) {
if (pingOutstanding) {
this->_state = MQTT_CONNECTION_TIMEOUT;
_client->stop();
Expand Down

0 comments on commit 30880ad

Please sign in to comment.