From 9b5f3c2882dcb4829ca7e6194df01fb263fc2c58 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Tue, 22 May 2018 11:04:32 -0700 Subject: [PATCH] Report connected when any bytes are available (#4754) The SSL pipeline is multi-stage, and the TCP connection can go down even though there is still data waiting to be decrypted or in the decryption buffer. Explicitly check that there if there can be any data made available to the app, and if so report that we are still connected(). When there is no data and there is no TCP connection, report disconnected. --- libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp b/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp index e94ad6357..5e641a678 100644 --- a/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp +++ b/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp @@ -228,10 +228,8 @@ bool WiFiClientSecure::_clientConnected() { } uint8_t WiFiClientSecure::connected() { - if (_recvapp_len) { - return true; - } - if (_client && _client->state() == ESTABLISHED && _handshake_done) { + if (WiFiClient::connected() || available() || + (_clientConnected() && _handshake_done)) { return true; } return false;