diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index a9523005..ca7021da 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -1029,7 +1029,7 @@ #endif #ifndef MQTT_KEEPALIVE -#define MQTT_KEEPALIVE 300 // MQTT keepalive value +#define MQTT_KEEPALIVE 120 // MQTT keepalive value #endif diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index eb8ed9d4..3a210ab3 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -187,6 +187,7 @@ bool _mqttConnectSyncClient(bool secure = false) { #if MQTT_LIBRARY == MQTT_LIBRARY_ARDUINOMQTT _mqtt.begin(_mqtt_server.c_str(), _mqtt_port, _mqttGetClient(secure)); _mqtt.setWill(_mqtt_will.c_str(), _mqtt_payload_offline.c_str(), _mqtt_retain, _mqtt_qos); + _mqtt.setKeepAlive(_mqtt_keepalive); result = _mqtt.connect(_mqtt_clientid.c_str(), _mqtt_user.c_str(), _mqtt_pass.c_str()); #elif MQTT_LIBRARY == MQTT_LIBRARY_PUBSUBCLIENT _mqtt.setClient(_mqttGetClient(secure)); diff --git a/code/platformio.ini b/code/platformio.ini index f630b631..b9cf8804 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -118,7 +118,7 @@ lib_deps = https://github.com/xoseperez/justwifi.git#2.0.2 https://github.com/madpilot/mDNSResolver#4cfcda1 https://github.com/xoseperez/my92xx#3.0.1 - MQTT + https://github.com/256dpi/arduino-mqtt#196556b6 https://bitbucket.org/xoseperez/nofuss.git#0.3.0 https://github.com/xoseperez/NtpClient.git#0942ebc OneWire