Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: No Captive Portal Notifications or Forwarding? #85

Closed
bazfp opened this issue Jun 1, 2019 · 5 comments
Closed

Android: No Captive Portal Notifications or Forwarding? #85

bazfp opened this issue Jun 1, 2019 · 5 comments
Labels
Under investigation It is under investigation and new information is posted on a sequential basis.

Comments

@bazfp
Copy link

bazfp commented Jun 1, 2019

I'm running some simple code and I cannot get the captive portal to work.

It is accessible at http://192.168.244.1/_ac but I am not prompted on any device to access this page? I don't think the DNS is working correctly for captive portal?

Device: TTGO T-Beam ESP32

#include <WebServer.h>
#include <AutoConnect.h>

WebServer Server;
AutoConnect Portal(Server);

void setup() 
{
  delay(1000);
  Serial.begin(115200);
  Portal.begin();
  Serial.println("Starting web server");
}

void loop() 
{
  Portal.handleClient();
  // put your main code here, to run repeatedly:
}

Log:

[AC] WiFi.config(IP=0.0.0.0, Gateway=0.0.0.0, Subnetmask=0.0.0.0, DNS1=0.0.0.0, DNS2=0.0.0.0)
[E][WiFiSTA.cpp:211] begin(): connect failed!
[AC] WiFi.begin()
[AC] Connecting.....................................................................................................time out IP:0.0.0.0
[AC] SoftAP configure 192.168.244.1, 192.168.244.1, 255.255.255.0
[AC] SoftAP esp32ap/12345678 Ch(1) IP:192.168.244.1
[AC] http server started
[AC] DNS server started
[AC] Host:,URI:/,ignored
[E][WebServer.cpp:602] _handleRequest(): request handler not found
[PB] at leaving build: 266748 free
[AC] Host:192.168.244.1,URI:/,ignored
[E][WebServer.cpp:602] _handleRequest(): request handler not found
[AC] Detected application, ypmypnbwo, 0.0.0.0
[AC] Host:ypmypnbwo,URI:/,ignored
[E][WebServer.cpp:602] _handleRequest(): request handler not found
[AC] Detected application, jrowdoirylk, 0.0.0.0
[AC] Host:jrowdoirylk,URI:/,ignored
[E][WebServer.cpp:602] _handleRequest(): request handler not found
[AC] Detected application, imuicdkpddurvyh, 0.0.0.0
[AC] Host:imuicdkpddurvyh,URI:/_ac,generated:/_ac, allocated
[AC] Host:192.168.244.1,URI:/_ac,already allocated
[PB] at leaving build: 250248 free
[PB] Free heap:253256, content len.:6520
[PB] Res:200, Chunked:1
[E][WiFiClient.cpp:365] write(): fail on fd 60, errno: 104, "Connection reset by peer"
[AC] Host:192.168.244.1,URI:/_ac,already allocated
[AC] Host:192.168.244.1,URI:/_ac,already allocated
[PB] at leaving build: 252004 free
[PB] Free heap:255016, content len.:6520
[PB] Res:200, Chunked:1
[E][WiFiClient.cpp:365] write(): fail on fd 61, errno: 104, "Connection reset by peer"
[AC] Host:192.168.244.1,URI:/_ac,already allocated
[AC] Host:192.168.244.1,URI:/_ac,already allocated
[PB] at leaving build: 254092 free
[PB] Free heap:257108, content len.:6520
[PB] Res:200, Chunked:1
[E][WiFiClient.cpp:365] write(): fail on fd 62, errno: 104, "Connection reset by peer"
[AC] Host:192.168.244.1,URI:/_ac,already allocated
[AC] Host:192.168.244.1,URI:/_ac,already allocated
[PB] at leaving build: 253592 free
[PB] Free heap:256576, content len.:6520
[PB] Res:200, Chunked:1
@bazfp
Copy link
Author

bazfp commented Jun 1, 2019

It works for http requests but it would be nicer if I can get a platform specific captive portal detection. Is it somehow related to end point resolution?

https://socifi-doc.atlassian.net/wiki/spaces/SC/pages/94371841/DNS+Workaround+to+keep+Android+Splash+Page+and+the+Captive+Portal+Notification+active

@bazfp
Copy link
Author

bazfp commented Jun 2, 2019

I've solved it! I now get captive portal notifications and automatic forwarding to the captive portal on my Android devices (Samsung Galaxy S8) when I connect to the network. The solution was unintuitive but works.

Set the SoftAP apIP and apGatway to a WAN IP instead of default LAN 192.168.244.1. It probably works on other platforms too.

Recommend this should be the default (172.168.244.1 instead of 192.168.244.1)

AutoConnectDefs.h

#ifndef AUTOCONNECT_AP_IP
#define AUTOCONNECT_AP_IP 0x01F4A8AC  //*< 172.168.244.1 */
#endif // !AUTOCONNECT_AP_IP
#ifndef AUTOCONNECT_AP_GW
#define AUTOCONNECT_AP_GW 0x01F4A8AC  //*< 172.168.244.1 */
#endif // !AUTOCONNECT_AP_GW

image

Solution: tzapu/WiFiManager#553 (comment)

@bazfp bazfp changed the title ESP32 No Captive Portal? Android: No Captive Portal Notifications or Forwarding? Jun 2, 2019
@Hieromon
Copy link
Owner

Hieromon commented Jun 3, 2019

@bazfp Thank you for your information. This phenomenon is already discussed in arduino-esp32 core repositories. espressif/arduino-esp32#1037
As per your suggestion, PR has been requested to change the SoftAP's default with the esp8266 core. esp8266/Arduino#5529
But the PR is not accepted for now. In my view, I think d-v-a's claim to the PR is right and 172.168.xxx.xxx is not a private range. It is an issue that depends on the implementation of captive portal detection in a specific version of AndroidOS.
I cannot confirm the following option because I do not have any Android devices that experience this symptom, but have you tried the following options on your device? (Related issue #33)
Its option seems to be related to the address range for the captive portal detection.
tzapu/WiFiManager#553 (comment)

However, I will keep it open for users with a similar problem, as it may be useful as a temporary workaround for a particular mobile OS.

@Hieromon Hieromon pinned this issue Jun 3, 2019
@Hieromon Hieromon added the Under investigation It is under investigation and new information is posted on a sequential basis. label Jun 5, 2019
@Hieromon
Copy link
Owner

@bazfp, I decided to solve this problem by taking your solution that according to the PR. The following quote is causing.

in order to get a captive notification to show or the popup to open, the DNS server must resolve to a public IP. It will not work with a private one (e.g. 192.168.4.1).

On Android, a notification ("Register with Network") is displayed in the top left notification bar.
On IOS, the login popup is displayed.

Default softAPIP and gateway IP for the captive portal activation have been changed to 172.217.28.1. IP-range 172.217.0.0/16 has assigned to Google LLC so I used the range for new SoftAP IP to support newer Android.
Please try a new release as v0.9.12.

@Hieromon
Copy link
Owner

Hieromon commented Sep 7, 2019

Closes until a new phenomenon occurs caused by the SoftAP default IP has changed.
It will reopen if the issue recurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Under investigation It is under investigation and new information is posted on a sequential basis.
Projects
None yet
Development

No branches or pull requests

2 participants