From be36218b846099fee336d03df30c5f3684fc3c42 Mon Sep 17 00:00:00 2001 From: Theo Arends Date: Wed, 25 Apr 2018 18:25:25 +0200 Subject: [PATCH] Possible 2.4.1 memory leak fix (#2544) --- sonoff/xdrv_00_mqtt.ino | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sonoff/xdrv_00_mqtt.ino b/sonoff/xdrv_00_mqtt.ino index 68b3c6a70..7d47f37b5 100644 --- a/sonoff/xdrv_00_mqtt.ino +++ b/sonoff/xdrv_00_mqtt.ino @@ -399,6 +399,11 @@ boolean MqttCheckTls() } AddLog_P(LOG_LEVEL_INFO, S_LOG_MQTT, PSTR(D_FINGERPRINT)); + +//#ifdef ARDUINO_ESP8266_RELEASE_2_4_1 + EspClient = WiFiClientSecure(); // Wifi Secure Client reconnect issue 4497 (https://github.com/esp8266/Arduino/issues/4497) +//#endif + if (!EspClient.connect(Settings.mqtt_host, Settings.mqtt_port)) { snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_TLS_CONNECT_FAILED_TO " %s:%d. " D_RETRY_IN " %d " D_UNIT_SECOND), Settings.mqtt_host, Settings.mqtt_port, mqtt_retry_counter); @@ -479,6 +484,14 @@ void MqttReconnect() mqtt_initial_connection_state = 1; } +//#ifdef ARDUINO_ESP8266_RELEASE_2_4_1 +#ifdef USE_MQTT_TLS + EspClient = WiFiClientSecure(); // Wifi Secure Client reconnect issue 4497 (https://github.com/esp8266/Arduino/issues/4497) +#else + EspClient = WiFiClient(); // Wifi Client reconnect issue 4497 (https://github.com/esp8266/Arduino/issues/4497) +#endif +//#endif + #if (MQTT_LIBRARY_TYPE == MQTT_PUBSUBCLIENT) MqttClient.setCallback(MqttDataHandler); MqttClient.setServer(Settings.mqtt_host, Settings.mqtt_port);