tzapu / WiFiManager

ESP8266 WiFi Connection manager with web captive portal
http://tzapu.com/esp8266-wifi-connection-manager-library-arduino-ide/
MIT License
6.6k stars 1.97k forks source link

Wifi Disconnection during captive portal on XH-C3F sparkleiot #1582

Open micdj opened 1 year ago

micdj commented 1 year ago

Basic Infos

Hardware

WiFimanager Branch/Release: Master

Esp8266/Esp32:

Hardware: XH-C3F

Core Version: 2.0.7

Description

During captive portal, in softAP with all basic examples, wifi disconnect from client on alla platform(windows, ios and android) but softAP is up, if I reconnect it start again and open captive portal automatically again, then could work or disconnect again.

Settings in IDE

Module:
ESP32C3 Dev Module

Sketch

include // https://github.com/tzapu/WiFiManager

void setup() { // WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP // it is a good practice to make sure your code sets wifi mode how you want it.

// put your setup code here, to run once:
Serial.begin(115200);

//WiFiManager, Local intialization. Once its business is done, there is no need to keep it around
WiFiManager wm;

// reset settings - wipe stored credentials for testing
// these are stored by the esp library
// wm.resetSettings();

// Automatically connect using saved credentials,
// if connection fails, it starts an access point with the specified name ( "AutoConnectAP"),
// if empty will auto generate SSID, if password is blank it will be anonymous AP (wm.autoConnect())
// then goes into a blocking loop awaiting configuration and will return success result

bool res;
// res = wm.autoConnect(); // auto generated AP name from chipid
// res = wm.autoConnect("AutoConnectAP"); // anonymous ap
res = wm.autoConnect("AutoConnectAP","password"); // password protected ap

if(!res) {
    Serial.println("Failed to connect");
    // ESP.restart();
} 
else {
    //if you get here you have connected to the WiFi    
    Serial.println("connected...yeey :)");
}

}

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

Debug Messages

20:17:49.346 -> ESP-ROM:esp32c3-api1-20210207 20:17:49.346 -> Build:Feb 7 2021 20:17:49.346 -> rst:0x1 (POWERON),boot:0xd (SPI_FAST_FLASH_BOOT) 20:17:49.346 -> SPIWP:0xee 20:17:49.346 -> mode:DIO, clock div:2 20:17:49.346 -> load:0x3fcd5810,len:0x438 20:17:49.346 -> load:0x403cc710,len:0x91c 20:17:49.346 -> load:0x403ce710,len:0x25b0 20:17:49.346 -> entry 0x403cc710 20:17:49.533 -> wm:AutoConnect 20:17:49.533 -> [ 198][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 0 - WIFI_READY 20:17:49.533 -> [ 230][V][WiFiGeneric.cpp:340] _arduino_event_cb(): STA Started 20:17:49.580 -> [ 230][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 2 - STA_START 20:17:49.580 -> wm:No wifi saved, skipping 20:17:49.580 -> wm:AutoConnect: FAILED 20:17:49.580 -> [ 245][V][WiFiGeneric.cpp:392] _arduino_event_cb(): AP Started 20:17:49.580 -> [ 245][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 10 - AP_START 20:17:49.580 -> [ 252][V][WiFiGeneric.cpp:343] _arduino_event_cb(): STA Stopped 20:17:49.580 -> [ 255][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 3 - STA_STOP 20:17:49.580 -> wm:StartAP with SSID: AutoConnectAP 20:17:50.190 -> [ 873][V][WiFiGeneric.cpp:395] _arduino_event_cb(): AP Stopped 20:17:50.190 -> [ 874][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 11 - AP_STOP 20:17:50.190 -> [ 876][V][WiFiGeneric.cpp:392] _arduino_event_cb(): AP Started 20:17:50.237 -> [ 881][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 10 - AP_START 20:17:50.703 -> wm:AP IP address: 192.168.4.1 20:17:50.703 -> wm:Starting Web Portal 20:17:50.703 -> [ 1389][V][WiFiServer.h:42] WiFiServer(): WiFiServer::WiFiServer(port=80, ...) 20:17:50.703 -> [ 1389][V][WebServer.cpp:87] WebServer(): WebServer::Webserver(port=80) 20:17:50.750 -> [ 1399][V][WiFiGeneric.cpp:340] _arduino_event_cb(): STA Started 20:17:50.750 -> [ 1402][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 2 - STA_START 20:17:57.758 -> [ 8443][V][WiFiGeneric.cpp:383] _arduino_event_cb(): SCAN Done: ID: 128, Status: 0, Results: 7 20:17:57.758 -> [ 8444][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 1 - SCAN_DONE 20:18:06.386 -> [ 17038][V][WiFiGeneric.cpp:407] _arduino_event_cb(): AP Station Connected: MAC: 30:e3:7a:31:b2:3a, AID: 1 20:18:06.386 -> [ 17038][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 12 - AP_STACONNECTED 20:18:06.522 -> [ 17178][V][WiFiGeneric.cpp:421] _arduino_event_cb(): AP Station IP Assigned:192.168.4.2 20:18:06.522 -> [ 17179][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 14 - AP_STAIPASSIGNED 20:18:06.607 -> [ 17264][V][WebServer.cpp:296] handleClient(): New client: client.localIP()=192.168.4.1 20:18:06.607 -> [ 17266][V][Parsing.cpp:122] _parseRequest(): method: GET url: /connecttest.txt search: 20:18:06.607 -> [ 17270][V][Parsing.cpp:226] _parseRequest(): headerName: Cache-Control 20:18:06.607 -> [ 17275][V][Parsing.cpp:227] _parseRequest(): headerValue: no-cache 20:18:06.607 -> [ 17282][V][Parsing.cpp:226] _parseRequest(): headerName: Connection 20:18:06.607 -> [ 17288][V][Parsing.cpp:227] _parseRequest(): headerValue: Close 20:18:06.607 -> [ 17293][V][Parsing.cpp:226] _parseRequest(): headerName: Pragma 20:18:06.654 -> [ 17299][V][Parsing.cpp:227] _parseRequest(): headerValue: no-cache 20:18:06.654 -> [ 17305][V][Parsing.cpp:226] _parseRequest(): headerName: User-Agent 20:18:06.654 -> [ 17311][V][Parsing.cpp:227] _parseRequest(): headerValue: Microsoft NCSI 20:18:06.654 -> [ 17318][V][Parsing.cpp:226] _parseRequest(): headerName: Host 20:18:06.654 -> [ 17323][V][Parsing.cpp:227] _parseRequest(): headerValue: www.msftconnecttest.com 20:18:06.654 -> [ 17330][V][Parsing.cpp:254] _parseArguments(): args: 20:18:06.654 -> [ 17335][V][Parsing.cpp:237] _parseRequest(): Request: /connecttest.txt 20:18:06.654 -> [ 17342][V][Parsing.cpp:238] _parseRequest(): Arguments: 20:18:06.654 -> [ 17347][E][WebServer.cpp:649] _handleRequest(): request handler not found 20:18:06.703 -> [ 17354][W][WebServer.cpp:436] send(): content length is zero 20:18:07.027 -> [ 17683][V][WebServer.cpp:296] handleClient(): New client: client.localIP()=192.168.4.1 20:18:07.027 -> [ 17685][V][Parsing.cpp:122] _parseRequest(): method: GET url: /connecttest.txt search: 20:18:07.027 -> [ 17689][V][Parsing.cpp:226] _parseRequest(): headerName: Connection 20:18:07.027 -> [ 17694][V][Parsing.cpp:227] _parseRequest(): headerValue: Close 20:18:07.027 -> [ 17700][V][Parsing.cpp:226] _parseRequest(): headerName: User-Agent 20:18:07.027 -> [ 17706][V][Parsing.cpp:227] _parseRequest(): headerValue: Microsoft NCSI 20:18:07.027 -> [ 17713][V][Parsing.cpp:226] _parseRequest(): headerName: Host 20:18:07.074 -> [ 17718][V][Parsing.cpp:227] _parseRequest(): headerValue: www.msftconnecttest.com 20:18:07.074 -> [ 17726][V][Parsing.cpp:254] _parseArguments(): args: 20:18:07.074 -> [ 17730][V][Parsing.cpp:237] _parseRequest(): Request: /connecttest.txt 20:18:07.074 -> [ 17737][V][Parsing.cpp:238] _parseRequest(): Arguments: 20:18:07.074 -> [ 17742][E][WebServer.cpp:649] _handleRequest(): request handler not found 20:18:07.074 -> [ 17749][W][WebServer.cpp:436] send(): content length is zero 20:18:07.074 -> [ 17759][V][WebServer.cpp:296] handleClient(): New client: client.localIP()=192.168.4.1 20:18:07.074 -> [ 17763][V][Parsing.cpp:122] _parseRequest(): method: GET url: /connecttest.txt search: 20:18:07.121 -> [ 17770][V][Parsing.cpp:226] _parseRequest(): headerName: Cache-Control 20:18:07.121 -> [ 17776][V][Parsing.cpp:227] _parseRequest(): headerValue: no-cache 20:18:07.121 -> [ 17782][V][Parsing.cpp:226] _parseRequest(): headerName: Connection 20:18:07.121 -> [ 17788][V][Parsing.cpp:227] _parseRequest(): headerValue: Close 20:18:07.121 -> [ 17794][V][Parsing.cpp:226] _parseRequest(): headerName: Pragma 20:18:07.121 -> [ 17799][V][Parsing.cpp:227] _parseRequest(): headerValue: no-cache 20:18:07.121 -> [ 17805][V][Parsing.cpp:226] _parseRequest(): headerName: User-Agent 20:18:07.121 -> [ 17811][V][Parsing.cpp:227] _parseRequest(): headerValue: Microsoft NCSI 20:18:07.168 -> [ 17818][V][Parsing.cpp:226] _parseRequest(): headerName: Host 20:18:07.168 -> [ 17823][V][Parsing.cpp:227] _parseRequest(): headerValue: www.msftconnecttest.com 20:18:07.168 -> [ 17831][V][Parsing.cpp:254] _parseArguments(): args: 20:18:07.168 -> [ 17836][V][Parsing.cpp:237] _parseRequest(): Request: /connecttest.txt 20:18:07.168 -> [ 17842][V][Parsing.cpp:238] _parseRequest(): Arguments: 20:18:07.168 -> [ 17847][E][WebServer.cpp:649] _handleRequest(): request handler not found 20:18:07.168 -> [ 17854][W][WebServer.cpp:436] send(): content length is zero 20:18:07.449 -> [ 18104][V][WebServer.cpp:296] handleClient(): New client: client.localIP()=192.168.4.1 20:18:07.449 -> [ 18105][V][Parsing.cpp:122] _parseRequest(): method: GET url: /connecttest.txt search: 20:18:07.449 -> [ 18109][V][Parsing.cpp:226] _parseRequest(): headerName: Connection 20:18:07.449 -> [ 18115][V][Parsing.cpp:227] _parseRequest(): headerValue: Close 20:18:07.449 -> [ 18121][V][Parsing.cpp:226] _parseRequest(): headerName: User-Agent 20:18:07.449 -> [ 18127][V][Parsing.cpp:227] _parseRequest(): headerValue: Microsoft NCSI 20:18:07.449 -> [ 18133][V][Parsing.cpp:226] _parseRequest(): headerName: Host 20:18:07.449 -> [ 18139][V][Parsing.cpp:227] _parseRequest(): headerValue: www.msftconnecttest.com 20:18:07.496 -> [ 18146][V][Parsing.cpp:254] _parseArguments(): args: 20:18:07.496 -> [ 18151][V][Parsing.cpp:237] _parseRequest(): Request: /connecttest.txt 20:18:07.496 -> [ 18157][V][Parsing.cpp:238] _parseRequest(): Arguments: 20:18:07.496 -> [ 18163][E][WebServer.cpp:649] _handleRequest(): request handler not found 20:18:07.496 -> [ 18169][W][WebServer.cpp:436] send(): content length is zero 20:18:09.546 -> [ 20222][V][WebServer.cpp:296] handleClient(): New client: client.localIP()=192.168.4.1 20:18:09.829 -> [ 20504][D][WiFiClient.cpp:546] connected(): Disconnected: RES: 0, ERR: 128 20:18:09.919 -> [ 20573][V][WebServer.cpp:296] handleClient(): New client: client.localIP()=192.168.4.1 20:18:09.919 -> [ 20575][E][Parsing.cpp:90] _parseRequest(): Invalid request:  20:18:11.835 -> [ 22526][V][WebServer.cpp:296] handleClient(): New client: client.localIP()=192.168.4.1 20:18:16.860 -> [ 27530][V][WebServer.cpp:296] handleClient(): New client: client.localIP()=192.168.4.1 20:18:16.860 -> [ 27531][V][Parsing.cpp:122] _parseRequest(): method: GET url: /redirect search: 20:18:16.860 -> [ 27535][V][Parsing.cpp:226] _parseRequest(): headerName: Host 20:18:16.860 -> [ 27540][V][Parsing.cpp:227] _parseRequest(): headerValue: www.msftconnecttest.com 20:18:16.860 -> [ 27547][V][Parsing.cpp:226] _parseRequest(): headerName: Connection 20:18:16.906 -> [ 27553][V][Parsing.cpp:227] _parseRequest(): headerValue: keep-alive 20:18:16.906 -> [ 27560][V][Parsing.cpp:226] _parseRequest(): headerName: Cache-Control 20:18:16.906 -> [ 27566][V][Parsing.cpp:227] _parseRequest(): headerValue: max-age=0 20:18:16.906 -> [ 27572][V][Parsing.cpp:226] _parseRequest(): headerName: Upgrade-Insecure-Requests 20:18:16.906 -> [ 27579][V][Parsing.cpp:227] _parseRequest(): headerValue: 1 20:18:16.906 -> [ 27585][V][Parsing.cpp:226] _parseRequest(): headerName: User-Agent 20:18:16.906 -> [ 27591][V][Parsing.cpp:227] _parseRequest(): headerValue: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 20:18:16.952 -> [ 27606][V][Parsing.cpp:226] _parseRequest(): headerName: Accept 20:18:16.952 -> [ 27611][V][Parsing.cpp:227] _parseRequest(): headerValue: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7 20:18:16.952 -> [ 27629][V][Parsing.cpp:226] _parseRequest(): headerName: Accept-Encoding 20:18:16.952 -> [ 27635][V][Parsing.cpp:227] _parseRequest(): headerValue: gzip, deflate 20:18:16.952 -> [ 27642][V][Parsing.cpp:226] _parseRequest(): headerName: Accept-Language 20:18:16.998 -> [ 27648][V][Parsing.cpp:227] _parseRequest(): headerValue: it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6 20:18:16.998 -> [ 27657][V][Parsing.cpp:254] _parseArguments(): args: 20:18:16.998 -> [ 27662][V][Parsing.cpp:237] _parseRequest(): Request: /redirect 20:18:16.998 -> [ 27667][V][Parsing.cpp:238] _parseRequest(): Arguments: 20:18:16.998 -> [ 27673][E][WebServer.cpp:649] _handleRequest(): request handler not found 20:18:16.998 -> [ 27680][W][WebServer.cpp:436] send(): content length is zero 20:18:16.998 -> [ 27689][V][WebServer.cpp:296] handleClient(): New client: client.localIP()=192.168.4.1 20:18:22.010 -> [ 32696][V][WebServer.cpp:296] handleClient(): New client: client.localIP()=192.168.4.1 20:18:22.010 -> [ 32699][E][Parsing.cpp:90] _parseRequest(): Invalid request:  20:18:22.010 -> [ 32701][V][WebServer.cpp:296] handleClient(): New client: client.localIP()=192.168.4.1 20:18:22.056 -> [ 32708][V][Parsing.cpp:122] _parseRequest(): method: GET url: / search: 20:18:22.056 -> [ 32714][V][Parsing.cpp:226] _parseRequest(): headerName: Host 20:18:22.056 -> [ 32719][V][Parsing.cpp:227] _parseRequest(): headerValue: 192.168.4.1 20:18:22.056 -> [ 32725][V][Parsing.cpp:226] _parseRequest(): headerName: Connection 20:18:22.056 -> [ 32731][V][Parsing.cpp:227] _parseRequest(): headerValue: keep-alive 20:18:22.056 -> [ 32738][V][Parsing.cpp:226] _parseRequest(): headerName: Cache-Control 20:18:22.056 -> [ 32744][V][Parsing.cpp:227] _parseRequest(): headerValue: max-age=0 20:18:22.102 -> [ 32750][V][Parsing.cpp:226] _parseRequest(): headerName: Upgrade-Insecure-Requests 20:18:22.102 -> [ 32757][V][Parsing.cpp:227] _parseRequest(): headerValue: 1 20:18:22.102 -> [ 32763][V][Parsing.cpp:226] _parseRequest(): headerName: User-Agent 20:18:22.102 -> [ 32769][V][Parsing.cpp:227] _parseRequest(): headerValue: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 20:18:22.102 -> [ 32784][V][Parsing.cpp:226] _parseRequest(): headerName: Accept 20:18:22.102 -> [ 32789][V][Parsing.cpp:227] _parseRequest(): headerValue: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7 20:18:22.150 -> [ 32807][V][Parsing.cpp:226] _parseRequest(): headerName: Accept-Encoding 20:18:22.150 -> [ 32813][V][Parsing.cpp:227] _parseRequest(): headerValue: gzip, deflate 20:18:22.150 -> [ 32820][V][Parsing.cpp:226] _parseRequest(): headerName: Accept-Language 20:18:22.150 -> [ 32826][V][Parsing.cpp:227] _parseRequest(): headerValue: it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6 20:18:22.150 -> [ 32835][V][Parsing.cpp:254] _parseArguments(): args: 20:18:22.150 -> [ 32840][V][Parsing.cpp:237] _parseRequest(): Request: / 20:18:22.196 -> [ 32845][V][Parsing.cpp:238] _parseRequest(): Arguments: 20:18:29.941 -> [ 40615][V][WebServer.cpp:296] handleClient(): New client: client.localIP()=192.168.4.1 20:18:29.941 -> [ 40618][V][Parsing.cpp:122] _parseRequest(): method: GET url: /wifi search: 20:18:29.941 -> [ 40619][V][Parsing.cpp:226] _parseRequest(): headerName: Host 20:18:29.941 -> [ 40624][V][Parsing.cpp:227] _parseRequest(): headerValue: 192.168.4.1 20:18:29.941 -> [ 40631][V][Parsing.cpp:226] _parseRequest(): headerName: Connection 20:18:29.987 -> [ 40637][V][Parsing.cpp:227] _parseRequest(): headerValue: keep-alive 20:18:29.987 -> [ 40643][V][Parsing.cpp:226] _parseRequest(): headerName: Upgrade-Insecure-Requests 20:18:29.987 -> [ 40650][V][Parsing.cpp:227] _parseRequest(): headerValue: 1 20:18:29.987 -> [ 40656][V][Parsing.cpp:226] _parseRequest(): headerName: User-Agent 20:18:29.987 -> [ 40662][V][Parsing.cpp:227] _parseRequest(): headerValue: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 20:18:29.987 -> [ 40677][V][Parsing.cpp:226] _parseRequest(): headerName: Accept 20:18:30.034 -> [ 40682][V][Parsing.cpp:227] _parseRequest(): headerValue: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7 20:18:30.034 -> [ 40699][V][Parsing.cpp:226] _parseRequest(): headerName: Referer 20:18:30.034 -> [ 40705][V][Parsing.cpp:227] _parseRequest(): headerValue: http://192.168.4.1/ 20:18:30.034 -> [ 40712][V][Parsing.cpp:226] _parseRequest(): headerName: Accept-Encoding 20:18:30.034 -> [ 40718][V][Parsing.cpp:227] _parseRequest(): headerValue: gzip, deflate 20:18:30.034 -> [ 40725][V][Parsing.cpp:226] _parseRequest(): headerName: Accept-Language 20:18:30.081 -> [ 40731][V][Parsing.cpp:227] _parseRequest(): headerValue: it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6 20:18:30.081 -> [ 40741][V][Parsing.cpp:254] _parseArguments(): args: 20:18:30.081 -> [ 40746][V][Parsing.cpp:237] _parseRequest(): Request: /wifi 20:18:30.081 -> [ 40751][V][Parsing.cpp:238] _parseRequest(): Arguments: 20:18:36.706 -> [ 47390][V][WiFiGeneric.cpp:383] _arduino_event_cb(): SCAN Done: ID: 129, Status: 0, Results: 5 20:18:36.706 -> [ 47390][D][WiFiGeneric.cpp:931] _eventCallback(): Arduino Event: 1 - SCAN_DONE 20:18:36.706 -> *wm:5 networks found 20:18:36.751 -> [ 47414][V][WebServer.cpp:296] handleClient(): New client: client.localIP()=192.168.4.1

In this moment it disconnects

tablatronix commented 1 year ago

This is usually related to a flood of requests. I usually see this on apple devices. You can try making sure all eth are disconnected on the device before connecting?

micdj commented 1 year ago

All the eth on the esp? Yes esp Is in new flash state without any other connections

tablatronix commented 1 year ago

No the client device

micdj commented 1 year ago

No other connections on client, in different platforms