From fff23dac944879df6e15c65ca99a28d0e72e2000 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Tue, 22 May 2018 07:39:00 -0700 Subject: [PATCH] Report connected when any bytes are available 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. Fixes #4738 --- 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 e94ad63579..5e641a678e 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;