Skip to content

Commit

Permalink
Fix issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cziter15 committed Jun 19, 2024
1 parent 24ac410 commit 8b1b488
Showing 1 changed file with 0 additions and 23 deletions.
23 changes: 0 additions & 23 deletions src/ksf/comp/ksMqttConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,30 +89,7 @@ namespace ksf::comps
this->prefix = std::move(prefix);
this->broker = std::move(broker);

/*
* Set timeout for blocking calls (eg. connect). MQTT is handled async-like.
*
* There's an inconsistency in setTimeout implementation between Arduino for ESP32 and ESP8266.
* ESP32's WiFi client setTimeout method want seconds, while ESP8266's one wants milliseconds.
* I've wasted some time to get what's really going on here, but eventually caught that.
* Keep in mind that setTimeout wants time in seconds on ESP32 but getTimeout will return milliseconds.
*
* Timeout is required because underlying connect method is blocking. Without timeout it may trigger watchdog.
*
* Please be aware of bugs present in Arduino-esp32 framework:
* - https://github.com/espressif/arduino-esp32/issues/7350
* - https://github.com/espressif/arduino-esp32/issues/7356
* - https://github.com/espressif/arduino-esp32/issues/7355
*/

#if ESP32
netClientUq->setTimeout(KSF_MQTT_TIMEOUT_SEC);
netClientUq->setConnectionTimeout(KSF_SEC_TO_MS(KSF_MQTT_TIMEOUT_SEC));
#elif ESP8266
netClientUq->setTimeout(KSF_SEC_TO_MS(KSF_MQTT_TIMEOUT_SEC));
#else
#error Platform not implemented.
#endif

/* Load MQTT port. */
ksf::from_chars(port, portNumber);
Expand Down

0 comments on commit 8b1b488

Please sign in to comment.