mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #1144] Unable to access web page...!!! #980
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#980
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 @joykumarsen on GitHub (Nov 16, 2020).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1144
Hi,
The intension of the below program is to connect a WIFI network dynamically and to access a simple web page.
Issue :- Able to connect a WIFI network successfully, but not able to access any web page though the ESP32 module is connected in the STA Mode.
This is very unexpected error what i am facing. can you please help me or correct me if i am making any mistake in program. Your quick response will be highly appreciable.
The Arduino program is below:
Thank You.
@tablatronix commented on GitHub (Nov 16, 2020):
probably because wm already runs a webserver
@joykumarsen commented on GitHub (Nov 16, 2020):
Sir,
Is there a way to soft reset the board?
Because i observed that after pressing the rest button available in board, i can able to access the web page.
@tablatronix commented on GitHub (Nov 16, 2020):
esp.reset
but you can either destroy the wm instance, or just use the wm webserver instance. wm.server is a shared pointer
see the dev/ example
void bindServerCallback(){
wm.server->on("/custom",handleRoute);
// wm.server->on("/info",handleRoute); // you can override wm!
}
@joykumarsen commented on GitHub (Nov 17, 2020):
Thanks.
The way you suggested i can able to access the webpage only when the board is in AP mode. But as per my requirement i want to access it when the ESP32 module is in STA mode.
Is there a way to access the webpage when the board will connected to WIFI network and work as a STA?
Your suggestion will help me to move ahead in my project.
@tablatronix commented on GitHub (Nov 17, 2020):
Yes see the ondemand/non blocking webportal exampples.
The webportal can now be started by itself without configportal
There is not a way to leave it running, you just have to start it with that call
@joykumarsen commented on GitHub (Nov 18, 2020):
First of all thank you so much for giving your valuable time and guidance.
With the help of webportal, webserver can be accessible now. But it is possible only when i am resetting the module once.
Is it necessary or mandatory to reset the ESP32 module to access the webportal using local IP address...? Though the module is already in STA mode.
If reset is not required, i request you to have a look into the program (wrote just for trial) mentioned below. May be i am missing something and you can correct me.
I tried to soft reset the board using ESP.restart(), but it is running infinite times and not allowing to execute the remaining source code.
#include <WiFiManager.h>
WiFiManager wm;
void handle_root()
<html>\ \{
String HTML = "\
Welcome
\Your first Iot Project made with ESP32
\😊
\ \ </html>";wm.server->send(200, "text/html", HTML);
}
void handleRoute(){
Serial.println("[HTTP] handle route");
wm.server->send(200, "text/plain", "hello from user code");
}
void bindServerCallback()
{
wm.server->on("/webpage",handle_root);
wm.server->on("/custom",handleRoute);
}
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
IPAddress _ip = IPAddress(192, 168, 1, 120);
IPAddress _gw = IPAddress(192, 168, 1, 1);
IPAddress _sn = IPAddress(255, 255, 255, 0);
wm.setSTAStaticIPConfig(_ip, _gw, _sn);
wm.setWebServerCallback(bindServerCallback);
//wm.setHostname("WIFIMANAGERTESTING");
if (!wm.autoConnect("ESP32AP", "12345678"))
{
Serial.println("failed to connect, we should reset as see if it connects");
delay(3000);
//ESP.reset();
delay(5000);
}
else
{
//if you get here you have connected to the WiFi
Serial.println("WiFi Connected...");
Serial.println("local ip");
Serial.println(WiFi.localIP());
//wm.stopConfigPortal();
wm.startWebPortal();
}
}
void loop()
{
wm.process();
}
@tablatronix commented on GitHub (Nov 18, 2020):
hmm it should work, let me test.
It sounds like you are having a connection issue to wifi
@petermagdy94 commented on GitHub (Jan 2, 2021):
i finally find a way for that and hope it's correct and works with you.
Problem i faced:
when i enter the wifi credentials in wifi manager and after the esp32 is connected to the wifi network, then i can't access my custom webserver unless i make a manual hard reset.
Solution:
after wifimanager is finished, call server.close() then server.begin() for my webserver object.
Code:
@tablatronix commented on GitHub (Jan 3, 2021):
#1142
@petermagdy94 commented on GitHub (Jan 3, 2021):
ok i tried again today and it didn't work :(
so i make a wifi event on SYSTEM_EVENT_AP_STOP and in the callback function i made a soft reset ESP.reset();
it's working till now using esp32 and development branch.
@tablatronix commented on GitHub (Jan 4, 2021):
Yeah, I am investigating why the ports are not closing, pretty sure this is a esp bug
@microicRI commented on GitHub (Feb 16, 2022):
you should set dns1 and dns 2 IP address, looks like both are set to 0.0.0.0
after I set IPAddress dns1(192, 168, 1, 1); //Google dns , all works ok