Skip to content

Commit

Permalink
Possible 2.4.1 memory leak fix (arendst#2544)
Browse files Browse the repository at this point in the history
  • Loading branch information
arendst committed Apr 25, 2018
1 parent b12a594 commit 1aacaed
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sonoff/xdrv_00_mqtt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1aacaed

Please sign in to comment.