[GH-ISSUE #588] Captive portal not sent after losing connection to AP and power cycle. #490

Closed
opened 2026-02-28 01:25:33 +03:00 by kerem · 4 comments
Owner

Originally created by @akshay-rsm on GitHub (Apr 10, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/588

Basic Infos

WiFimanager Branch/Release: Development/Master

Hardware: ESP-12e

Core Version: 2.4.1

Description

I have a NodeMCU that runs WiFiManager before connecting to a REST service.
These are the steps I follow:

  1. Start the captive portal after powering up.
  2. Enter the credentials of the AP I want to connect to.
  3. The ESP8266 connects to the AP without any problems.
  4. I intentionally disconnect the AP. The ESP8266 loses connection.
  5. I perform a power cycle on the ESP8266 to restart the captive portal to enter the credentials for another AP. It can't find the AP and starts the captive portal again. However, I am unable to connect to the config portal AP. Even if I manage to connect to the AP, the config page isn't sent to the device.
    The serial log, however, has entries stating "Request redirected to captive portal". Unfortunately the portal page was never sent to any of the clients.

I tried the development branch of WiFiManager as well. That couldn't even go past step 3. It gave the status WL_DISCONNECTED for one AP and WL_IDLE_STATUS for another.

Settings in IDE

Module: NodeMcu v1.0

Additional libraries: ESP8266WiFi, PubSubClient, aRest.h

Sketch

//needed for aRest
#include <ESP8266WiFi.h>         
#include <PubSubClient.h>
#include <aREST.h>

//needed for WiFiManager library
#include <ESP8266WebServer.h>
#include <DNSServer.h>
#include <WiFiManager.h>         

void setup() {
    //NodeMCU stuff
    Serial.begin(115200);
    pinMode(relay_pin,OUTPUT);
    digitalWrite(relay_pin,HIGH);
    
//arest stuff 
    client.setCallback(callback);
    set_arest_parameters(); 
    char* out_topic = rest.get_topic();
    
    WiFiManager wifiManager;              //WiFiManager
    //reset saved settings
    //wifiManager.resetSettings();
      
    //fetches ssid and pass from eeprom and tries to connect
    //if it does not connect it starts an access point with the specified name
    //and goes into a blocking loop awaiting configuration
    wifiManager.autoConnect();
    
    //if you get here you have connected to the WiFi
        
}

void loop() {
    // put your main code here, to run repeatedly:
    rest.handle(client);
}

Debug Messages

*WM: Connecting to new AP
*WM: Connecting as wifi client...
*WM: Already connected. Bailing out.
Attempting MQTT connection...Connected to aREST.io
Attempting MQTT connection...failed, rc=-2 try again in 5 seconds
Attempting MQTT connection...failed, rc=-2 try again in 5 seconds
Attempting MQTT connection...failed, rc=-2 try again in 5 seconds
.
(Reset the board)
.
.
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result: 
*WM: 1
*WM: SET AP STA
*WM: 
*WM: Configuring access point... 
*WM: ESP7688619
*WM: AP IP address: 
*WM: 192.168.4.1
*WM: HTTP server started
*WM: Request redirected to captive portal
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
Originally created by @akshay-rsm on GitHub (Apr 10, 2018). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/588 ### Basic Infos WiFimanager Branch/Release: Development/Master Hardware: ESP-12e Core Version: 2.4.1 ### Description I have a NodeMCU that runs WiFiManager before connecting to a REST service. These are the steps I follow: 1) Start the captive portal after powering up. 2) Enter the credentials of the AP I want to connect to. 3) The ESP8266 connects to the AP without any problems. 4) I intentionally disconnect the AP. The ESP8266 loses connection. 5) I perform a power cycle on the ESP8266 to restart the captive portal to enter the credentials for another AP. It can't find the AP and starts the captive portal again. However, I am unable to connect to the config portal AP. Even if I manage to connect to the AP, the config page isn't sent to the device. The serial log, however, has entries stating "Request redirected to captive portal". Unfortunately the portal page was never sent to any of the clients. I tried the development branch of WiFiManager as well. That couldn't even go past step 3. It gave the status WL_DISCONNECTED for one AP and WL_IDLE_STATUS for another. ### Settings in IDE Module: NodeMcu v1.0 Additional libraries: ESP8266WiFi, PubSubClient, aRest.h ### Sketch ```cpp //needed for aRest #include <ESP8266WiFi.h> #include <PubSubClient.h> #include <aREST.h> //needed for WiFiManager library #include <ESP8266WebServer.h> #include <DNSServer.h> #include <WiFiManager.h> void setup() { //NodeMCU stuff Serial.begin(115200); pinMode(relay_pin,OUTPUT); digitalWrite(relay_pin,HIGH); //arest stuff client.setCallback(callback); set_arest_parameters(); char* out_topic = rest.get_topic(); WiFiManager wifiManager; //WiFiManager //reset saved settings //wifiManager.resetSettings(); //fetches ssid and pass from eeprom and tries to connect //if it does not connect it starts an access point with the specified name //and goes into a blocking loop awaiting configuration wifiManager.autoConnect(); //if you get here you have connected to the WiFi } void loop() { // put your main code here, to run repeatedly: rest.handle(client); } ``` ### Debug Messages ``` *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Already connected. Bailing out. Attempting MQTT connection...Connected to aREST.io Attempting MQTT connection...failed, rc=-2 try again in 5 seconds Attempting MQTT connection...failed, rc=-2 try again in 5 seconds Attempting MQTT connection...failed, rc=-2 try again in 5 seconds . (Reset the board) . . *WM: AutoConnect *WM: Connecting as wifi client... *WM: Using last saved values, should be faster *WM: Connection result: *WM: 1 *WM: SET AP STA *WM: *WM: Configuring access point... *WM: ESP7688619 *WM: AP IP address: *WM: 192.168.4.1 *WM: HTTP server started *WM: Request redirected to captive portal *WM: Request redirected to captive portal *WM: Handle root *WM: Request redirected to captive portal *WM: Handle root *WM: Request redirected to captive portal *WM: Handle root *WM: Request redirected to captive portal *WM: Handle root ```
kerem closed this issue 2026-02-28 01:25:33 +03:00
Author
Owner

@tablatronix commented on GitHub (Apr 10, 2018):

You will have to test and submit this against development branch and provide that debug output.

The workaround for this issue is #425
I just commited it to hotfixes branch if you want to see if that is your problem.

Either way, development needs to be debugged and tested, so please provide those logs, no other maintenance will be done on master branch.

<!-- gh-comment-id:379933741 --> @tablatronix commented on GitHub (Apr 10, 2018): You will have to test and submit this against development branch and provide that debug output. The workaround for this issue is #425 I just commited it to hotfixes branch if you want to see if that is your problem. Either way, development needs to be debugged and tested, so please provide those logs, no other maintenance will be done on master branch.
Author
Owner

@tablatronix commented on GitHub (Apr 10, 2018):

I think I introduced a bug into development, that might be why it was failing, testing now

<!-- gh-comment-id:379935236 --> @tablatronix commented on GitHub (Apr 10, 2018): I think I introduced a bug into development, that might be why it was failing, testing now
Author
Owner

@tablatronix commented on GitHub (Apr 10, 2018):

fixed

<!-- gh-comment-id:379938587 --> @tablatronix commented on GitHub (Apr 10, 2018): fixed
Author
Owner

@akshay-rsm commented on GitHub (Apr 10, 2018):

Both fixes you suggested worked perfectly. Thanks!

<!-- gh-comment-id:380085969 --> @akshay-rsm commented on GitHub (Apr 10, 2018): Both fixes you suggested worked perfectly. Thanks!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#490
No description provided.