forked from me-no-dev/ESPAsyncWebServer
-
Notifications
You must be signed in to change notification settings - Fork 82
Closed
Labels
Description
Platform
ESP32
IDE / Tooling
PlatformIO
What happened?
I get the captive portal example not working on Android or iOS. It connected to the device and I can put in the router ip address, but there is no pop-up of the captive portal when connecting to the WiFi. It used to work with the old library (before the Repo changed names). Using esp32-s3-devkit.
Stack Trace
11:41:06.931 > Configuring access point...
Minimal Reproductible Example (MRE)
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov
#include <DNSServer.h>
#include <AsyncTCP.h>
#include <WiFi.h>
#include "ESPAsyncWebServer.h"
static DNSServer dnsServer;
static AsyncWebServer server(80);
class CaptiveRequestHandler : public AsyncWebHandler {
public:
bool canHandle(__unused AsyncWebServerRequest *request) const override {
return true;
}
void handleRequest(AsyncWebServerRequest *request) {
AsyncResponseStream *response = request->beginResponseStream("text/html");
response->print("<!DOCTYPE html><html><head><title>Captive Portal</title></head><body>");
response->print("<p>This is our captive portal front page.</p>");
response->printf("<p>You were trying to reach: http://%s%s</p>", request->host().c_str(), request->url().c_str());
response->printf("<p>Try opening <a href='http://%s'>this link</a> instead</p>", WiFi.softAPIP().toString().c_str());
response->print("</body></html>");
request->send(response);
}
};
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println("Configuring access point...");
if (!WiFi.softAP("esp-captive")) {
Serial.println("Soft AP creation failed.");
while (1);
}
dnsServer.start(53, "*", WiFi.softAPIP());
server.addHandler(new CaptiveRequestHandler()).setFilter(ON_AP_FILTER); // only when requested from AP
// more handlers...
server.begin();
}
void loop() {
dnsServer.processNextRequest();
}
I confirm that:
- I have read the documentation.
- I have searched for similar discussions.
- I have searched for similar issues.
- I have looked at the examples.
- I have upgraded to the lasted version of ESPAsyncWebServer (and AsyncTCP for ESP32).