Fix for api disconnect detection. (#2909)

Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
Peter Valkov 2022-02-19 11:36:19 +02:00 committed by GitHub
parent 88fbb0ffbb
commit e445d6aada
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -105,6 +105,7 @@ void APIConnection::loop() {
ESP_LOGW(TAG, "%s didn't respond to ping request in time. Disconnecting...", this->client_info_.c_str());
}
} else if (now - this->last_traffic_ > keepalive) {
ESP_LOGVV(TAG, "Sending keepalive PING...");
this->sent_ping_ = true;
this->send_ping_request(PingRequest());
}
@ -908,7 +909,7 @@ bool APIConnection::send_buffer(ProtoWriteBuffer buffer, uint32_t message_type)
}
return false;
}
this->last_traffic_ = millis();
// Do not set last_traffic_ on send
return true;
}
void APIConnection::on_unauthenticated_access() {