Skip to content

Commit 30880ad

Browse files
authored
Merge pull request #7 from damdo/fix-keepalive
fix: keepalive behviour when set to 0
2 parents e6cac2f + d471121 commit 30880ad

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/PubSubClient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ uint32_t PubSubClient::readPacket(uint8_t* lengthLength) {
370370
boolean PubSubClient::loop() {
371371
if (connected()) {
372372
unsigned long t = millis();
373-
if ((t - lastInActivity > this->keepAlive*1000UL) || (t - lastOutActivity > this->keepAlive*1000UL)) {
373+
if (((t - lastInActivity > this->keepAlive*1000UL) || (t - lastOutActivity > this->keepAlive*1000UL)) && keepAlive != 0) {
374374
if (pingOutstanding) {
375375
this->_state = MQTT_CONNECTION_TIMEOUT;
376376
_client->stop();

0 commit comments

Comments
 (0)