Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

In AP, DNS server always redirects to 192.168.4.1 no mater what APStaticIP is set to. #58

Closed
yiancar opened this issue Apr 25, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@yiancar
Copy link

yiancar commented Apr 25, 2021

Describe the bug

My understanding is that the intention of the code is to auto direct the user connected to the config portal once connected. Currently due to a misconfiguration in the DNS server if APStaticIP is set the user has to enter the IP of APStaticIP to the browser.

This is because the DNS server is configured with WiFi.softAPIP() before softAP itself has been given the value of APStaticIP.

Esentially the DNS entry always redirects to 192.168.4.1.

Steps to Reproduce

Use the ESP32_FSWebServer_DRD sketch.
Connect to AP.
Config page only appears when 192.168.100.1 is used in the browser.

Proposed solution

DNS Setup

if (! dnsServer->start(DNS_PORT, "*", WiFi.softAPIP()))
is before AP ip configuration
if (_WiFi_AP_IPconfig._ap_static_ip)
.
Either move DNS setup after the AP configuration or put another checker at DNS setup to check if APStaticIP is set.

@khoih-prog
Copy link
Owner

Hi @yiancar

Thanks a lot for your smart eyes which spot the puzzling-to-me captive-portal issue.

I've tested the fix and will release a new version within today with your contribution noted.

Waiting for more of your bug spotting. 👍

Best Regards,

@khoih-prog
Copy link
Owner

The preliminary test for you to enjoy 👍

Starting ConfigOnDoubleReset with DoubleResetDetect using LittleFS on ESP32_DEV
ESP_WiFiManager v1.6.0
ESP_DoubleResetDetector v1.1.1
[WM] RFC925 Hostname = ConfigOnDoubleReset
[WM] setAPStaticIPConfig
[WM] Set CORS Header to :  Your Access-Control-Allow-Origin
ESP Self-Stored: SSID = HueNet1, Pass = 12345678
[WM] * Add SSID =  HueNet1 , PW =  12345678
Got ESP Self-Stored Credentials. Timeout 120s for Config Portal
LittleFS Flag read = 0xD0D01234
doubleResetDetected
Saving config file...
Saving config file OK
Open Config Portal without Timeout: Double Reset Detected
Starting configuration portal.
[WM] WiFi.waitForConnectResult Done
[WM] SET AP
[WM] Custom AP IP/GW/Subnet =  192.168.232.1 192.168.232.1 255.255.255.0
[WM] Configuring AP SSID = ESP_E92DE6B4
[WM] AP PWD = MyESP_E92DE6B4
[WM] AP Channel = 2
[WM] AP IP address = 192.168.232.1
[WM] HTTP server started
[WM] ESP_WiFiManager::startConfigPortal : Enter loop
dhcps: send_nak>>udp_sendto result 0
[WM] Handle root
[WM] captivePortal: hostHeader =  192.168.232.1
[WM] captivePortal: hostHeader =  192.168.232.1
[WM] Handle root
[WM] captivePortal: hostHeader =  test.mosquitto.org
[WM] Request redirected to captive portal :  192.168.232.1     <==========  OK now
[WM] Handle root
[WM] captivePortal: hostHeader =  192.168.232.1

khoih-prog added a commit that referenced this issue Apr 25, 2021
### Releases v1.6.1

1. Fix captive-portal bug if Config Portal AP address is not default 192.168.4.1. Check [In AP, DNS server always redirects to 192.168.4.1 no mater what APStaticIP is set to. #58](#58)
2. Fix MultiWiFi bug.
@khoih-prog
Copy link
Owner

Hi @yiancar

The new ESP_WiFiManager releases v1.6.1 has just been published, with the note about your contribution in Contributions and Thanks

Cheers,


Releases v1.6.1

  1. Fix captive-portal bug if Config Portal AP address is not default 192.168.4.1. Check In AP, DNS server always redirects to 192.168.4.1 no mater what APStaticIP is set to. #58
  2. Fix MultiWiFi bug.

@khoih-prog khoih-prog added the bug Something isn't working label Apr 25, 2021
khoih-prog added a commit to khoih-prog/ESPAsync_WiFiManager that referenced this issue Apr 26, 2021
### Releases v1.7.1

1. Fix captive-portal bug if Config Portal AP address is not default 192.168.4.1. Check [In AP, DNS server always redirects to 192.168.4.1 no mater what APStaticIP is set to. #58](khoih-prog/ESP_WiFiManager#58)
2. Fix MultiWiFi bug.
@yiancar
Copy link
Author

yiancar commented Apr 26, 2021

Cheers thank you for the quick reply!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants