khoih-prog / ESP_WiFiManager

This is an ESP32 / ESP8266 WiFi Connection Manager with fallback web configuration portal. Use this library for configuring ESP32 (including ESP32-S2 and ESP32-C3), ESP8266 modules' WiFi, etc. Credentials at runtime. You can also specify static DNS servers, personalized HostName, fixed or random AP WiFi channel. With examples supporting ArduinoJson
MIT License
374 stars 97 forks source link

CloudFlare link in the default portal #21

Closed tom-dierckx closed 4 years ago

tom-dierckx commented 4 years ago

The default portal hangs on a request to a Cloadflare link for a javascript library. This effectively breaks the application on connected devices that do not have another link to the internet. Is this as intended? After blocking a request to the Cloadflare cdn on the client the self service portal works.

(The link in question https://cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.4/jstz.min.js)

Regards and thank you for the amazing work,

Tom

khoih-prog commented 4 years ago

@tom-dierckx

Thanks for using the library and your encouraging words.

The NTP access to cloudflare.com was an enhancement from a request for a special use case. See Feature Request! Firmware and Data (SPIFFS) update OTA and NTP Timezone #5

You can disable it if it's not necessary to avoid above-mentioned issue by either

  1. Edit ESP_WiFiManager.h, and modify the line to
// From v1.0.6 to enable NTP config
#define USE_ESP_WIFIMANAGER_NTP     false

from

// From v1.0.6 to enable NTP config
#define USE_ESP_WIFIMANAGER_NTP     true
  1. Edit ESP_WiFiManager.h, and modify the line to
#if 0
const char HTTP_SCRIPT_NTP[] PROGMEM = "<script src='https://cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.4/jstz.min.js'></script><script>var timezone=jstz.determine();console.log('Your timezone is:' + timezone.name());document.getElementById('timezone').innerHTML = timezone.name();</script>";
#else

from

#if 1
const char HTTP_SCRIPT_NTP[] PROGMEM = "<script src='https://cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.4/jstz.min.js'></script><script>var timezone=jstz.determine();console.log('Your timezone is:' + timezone.name());document.getElementById('timezone').innerHTML = timezone.name();</script>";
#else

In future version, I'll add an option to let you define the option in sketch, instead of modifying the library directly, such as

#define USE_ESP_WIFIMANAGER_NTP       true
#define USE_CLOUDFLARE_NTP            true
#define USE_ESP_WIFIMANAGER_NTP       true
#define USE_CLOUDFLARE_NTP            false

or

#define USE_ESP_WIFIMANAGER_NTP       false
#define USE_CLOUDFLARE_NTP            false

Please test and let me know the results as well as your suggestions

Regards,