mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #553] ESP32 Captive Portal not loading on Android #463
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#463
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @fcjr on GitHub (Mar 14, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/553
Basic Infos
Hi,
I just pulled the latest development build of WiFiManager (as well as the latest version of the Arduino-ESP32 core which includes the latest DNSServer library (as suggested in https://github.com/espressif/arduino-esp32/issues/1186), however when running The AutoConnect Example (and others) I do not get a captive portal on any device. On Windows 10 and macOS (both latest) I am able to navigate to 192.168.4.1 or another non https page and it resolves to the ESP32, however no captive portal pops up on load. On android (8.1.0, latest) the issue seems to be more problematic, the device does not see any internet connection so it defaults to LTE and does not allow navigation to the ESP32 (even though it stays connected to the AP).
Are there some configuration steps I might be missing?
Thanks! - FC
Hardware
WiFimanager Branch/Release: Development
Hardware: espressif ESP32 DevKitC
Core Version: latest
@tablatronix commented on GitHub (Mar 14, 2018):
Dnsserver is no longer required, use the one in core
@fcjr commented on GitHub (Mar 14, 2018):
Hey @tablatronix, thanks for the reply! I am using the DNSServer library from the core, I am using the latest version of the core and am having the results stated above.
@tablatronix commented on GitHub (Mar 14, 2018):
confirmed, captiveportal in ondemand config portal works, autoconnect does not.Should be something dumb, will fix
@tablatronix commented on GitHub (Mar 14, 2018):
nope nevermind, I had the configportal timeout to short
@tablatronix commented on GitHub (Mar 14, 2018):
cant reproduce, windows 10 and IOS, both redirect to captive portal.
What do your logs show ?
@fcjr commented on GitHub (Mar 24, 2018):
Hi @tablatronix, thanks for your reply. I realized that the issue on my mac and pc was due to my antivirus blocking captive portals. (Sorry about that!) However there still seems to be an issue with android devices finding the captive portal. I've tried on both a Google Pixel and a Galaxy S8.
The Debug output simply states the following on connect:
*WM: NUM CLIENTS: 0
*WM: NUM CLIENTS: 1
The devices do seem to be getting the dns information properly however (see examples from pixel at end of this post). When attempting to navigate to a non https page (using chrome), or even directly via 192.168.4.1, the phones don't seem to even be making requests to the ESP. I have tested the devices on other captive portal systems (such as the guest wifi functionality on my home router, and both android phones pick up those portals fine).
If there is any more information I may be able to give you to help determine the problem please let me know!
@tablatronix commented on GitHub (Mar 24, 2018):
I do not have an android device to test unfortunately. I will try to obtain one.
When I had that problem it was a dns issue or firewall issue, Ill take a look at wireshark and see if everything looks ok, but its working for me everytime.
@treii28 commented on GitHub (Apr 1, 2018):
I've also been experiencing this trouble for some time. I have plenty of extra systems, wifi adapters, etc. around as well as multiple android and other devices. (no iOS but I can gain access to some if needed). I've been needing a pop-up style portal for over a year and have been searching and/or posting occasionally to try to find a solution.
I see the 'help wanted' and 'Needs Feedback'. I've only tinkered with wireshark a little, but if you can give me an idea what you want to see, I will do anything I can to get you data.
@nicogon commented on GitHub (Apr 2, 2018):
On android only works if you try to open a http page (not https). And is not automatic as in ios or a pc.
I've been researching about this, and it seems the problem is that android dont like that captive portal ip is in the same network. i've tested with a functional captive portal that dns resolves correctly (for android captive https://www.gstatic.com/generate_204 as an external ip) but it seems there is some kind of http redirection of the request to the captive portal.
@nicogon commented on GitHub (Apr 2, 2018):
dns service should give an external ip and then do some kind of http redirection (that i havent been able to do it with esp8266). Do you know if there is a way of intercepting http packet to an external ip and deliver a 302 redirection to the captive portal?
@tablatronix commented on GitHub (Apr 2, 2018):
Yeah I will keep tracking this here https://github.com/espressif/arduino-esp32/issues/1037#issuecomment-377962531
no need to continue posting here, as this is clearly not a wm issue.
I will keep it open in case we can find a workaround or solution for us, then update the captiveportal examples and vice versa.
I don't understand why this stuff is hard to come by, there should just be a developer whitepaper on this for andoid that clearly specifies what the deal is and how to get captive portals working.
@nicogon commented on GitHub (Apr 21, 2018):
Got it working on android by setting AP IP host to 172.217.28.1 (like if it was a wan ip) and network mask to 255.255.255.0.
I got the popup woking on android 7 (Samsung S7), Iphone 7 and OSX.
@JohnnyPP commented on GitHub (Apr 22, 2018):
@nicogon How did you exactly do it? I have been struggling with this problem for about two months.
@treii28 commented on GitHub (Apr 29, 2018):
I think the gist of it is that whatever the device will reject local IP dns responses for addresses it knows - or at least rejects local ips it knows for something it knows should be on the internet at large.
I've been trying to find either a code example or even a written explanation of just what things like OpenWRT do to make them work. My suspicion is that they don't simply redirect DNS like the arduino/esp code used to do but instead it actually intercepts internet traffic going to any other address than it's own and answers it as though it were the address in question.
Part of the problem on things like OpenWRT is that the people programming it aren't even 100% sure of the whole process because they rely on other people's tools such as IPTables to do some of the dirty work for them such as re-routing the packets. All they need to do then is answer them.
The ESP code core has lwip in with it to handle the IP stack. If I could find a good code example somewhere, I might be able to stab blindly around in the dark with my limited knowledge of C++ to try to do something similar until a given client was properly re-directed.
@tablatronix commented on GitHub (Jun 29, 2018):
Anyone figure anything new out?
@mattncsu commented on GitHub (Aug 6, 2018):
On your Android device, go to Advanced wifi options and disable the option to "Switch to mobile data - Switch to mobile data whenever your Wi-Fi internet connection is slow or unstable."
@hualde commented on GitHub (Sep 23, 2018):
P
@kbickham commented on GitHub (Aug 20, 2019):
I got this working by setting ip to 8.8.8.8 ot 8.8.4.4 and using port 53
@nabeelkirmani commented on GitHub (Nov 26, 2019):
Workaround
In file WiFiManager.cpp, in function
void WiFiManager::handleNotFound()replacing the400response code to200at Line 738 i.e.replacing
server->send ( 404, "text/plain", message );with
server->send ( 200, "text/plain", message );solves the issue of pop-up not appearing on my Windows 10 device. I tested this on the AutoConnect example in Sloeber IDE on NodeMCU 1.0 board.
I don't know why it worked but it did, and if someone can explain kindly do.
Whereas for my Android P & Windows 10 devices,
CaptivePortal.ino sketch works and brings up the pop-up captive portal.
@tablatronix commented on GitHub (Nov 26, 2019):
Thats interesting indeed, all requests should return the portal if its active..
Do you have or can you obtain serial logs of this ?
That handler should never be reached.
@nabeelkirmani commented on GitHub (Nov 27, 2019):
On building the project in the previously mentioned environment -
==============================================================
On connecting to WiFi on Android Pie mobile device -
No pop-up appears, so I open Google Chrome
Then I open https://www.debian.org and also https://www.debian.org/
Nothing in the serial output in both cases and Google Chrome shows ERR_CONNECTION_REFUSED
Then I open 192.168.4.1
*WM: Handle rootand it takes me to the captive portal.
When my Android Device is idle, this randomly appears multiple times -
*WM: Request redirected to captive portalNow I open http://www.debian.org and also http://www.debian.org/
and it successfully redirects me to the captive portal in both the cases.
==============================================================
I turn off and turn on my NodeMCU and on connecting to WiFi on Windows 10 laptop -
My default browser opens automatically and -
it redirects to the captive portal.
On opening HTTPS and HTTP links, it is the same story as with the Android Pie device.
@marianocrosetti commented on GitHub (Sep 1, 2021):
I found a similar behaviour when using WifiServer library:
When providing HTTP server for captive portal you generally have two options:
Using WebServer class and set handlers for roots. The parsing and handling of HTTP header is done by the library.
Use WifiServer and receive the HTTP message with header included and handler everything by your own.
If you are doing number 1 and pretend using by connecting with an Android device I suggest adding a handler for the error case showing the captive portal:
server.onNotFound(handleRoot);I noticed that for Android 10, to properly detect the captive portal and make the phone to show "Touch to log in the network" message is necesary. If not you must navigate to any HTTP address and let the DNS do the job for you (not HTTPS).
@tablatronix commented on GitHub (Sep 2, 2021):
So is this a problem with these dns failing and refusing to redirect? Ill look again but I am still confused how we are hitting the 404