mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #545] Server not working after portal connection. Only after manual reset. #457
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#457
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 @jwktje on GitHub (Mar 3, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/545
Basic Infos
Webserver responses only work on a reset after successfully connecting to a Wifi Network via the portal.
Hardware
WiFimanager Branch/Release: ESP32
Hardware: ESP32 (Wemos Lolin32)
Description
I'm using the bbx10 webserver and the ESP32 branch of WifiManager. Everything works great and stable since running these versions. But my only problem is that my server responses get a ERR_CONNECTION_REFUSED. When I reset the module and it already has the credentials, everything runs fine.
Sketch
Debug Messages
@jwktje commented on GitHub (Mar 3, 2018):
I found this gist but the BBX10 webserver misses this function it seems.
https://gist.github.com/tzapu/ecc0759829d30d5a6152
@tablatronix commented on GitHub (Mar 3, 2018):
what is in your loop ?
*WM: unloadingthis means your deconstructor is running, why is the class init and deinit over and over?Are there reboots in there?
@jwktje commented on GitHub (Mar 3, 2018):
My loop is this:
The only relevant piece in my code is just calling this:
Other functions don't do wifi related calls as far as I know. At the very least it doesn't use the wifi manager functions so I'm confused as to where the
*WM: Unloadingcomes fromUPDATE:
Just added some extra Serial prints, and the following logs happen automatically between the last line of my Setup() and the first Loop call:
@tablatronix commented on GitHub (Mar 3, 2018):
try the latest commit
@jwktje commented on GitHub (Mar 3, 2018):
Which branch? I'm on ESP32 now and pulled yesterday
@tablatronix commented on GitHub (Mar 3, 2018):
is it possible the webserver just doesn't support instances properly ?
can you create 2 webservers in your own scopes, without wifimanager?
@jwktje commented on GitHub (Mar 3, 2018):
Maybe yeah. I'm not fully up to speed on how the WebServer lib handles things. The gist I commented is for ESP8266 and the respective WebServer which has a reset function apparently.
Could I simulate this function somehow myself without changing the BBX10 Lib? As the Lib functions fine otherwise
@tablatronix commented on GitHub (Mar 3, 2018):
reset() is not part of the library, is a smart pointer method.
@jwktje commented on GitHub (Mar 3, 2018):
Ah right! So that's where my confusion came from. Thought is was a lib function. I'll rewrite all my dot notation calls to instance calls and see if that works! Good catch.
Update:
Rewrote all calls to reflect the Gist entirely and the sketch compiles and runs. But the problem still remains sadly. Going to a route in Chrome still gives ERR_CONNECTION_REFUSED after setting up via the portal without actually pressing the reset button on the device. I can ping the device however and it connects fine.
@tablatronix commented on GitHub (Mar 3, 2018):
Hmm ill try to test this myself and see what i can come up with.
@tablatronix commented on GitHub (Mar 4, 2018):
for some reason this doesnt work
server.reset(new my_WebServer(WiFi.localIP(), 80));it is running the wrong constructor and thinking ip is int, so port gets set to
xxx. of the ip instead of 80My server is found on port 10 for example.
just remove it it should work
server.reset(new my_WebServer();here my gist for esp32 esp8266
https://gist.github.com/tablatronix/e57dc3096ea311dd0e59aa512b8fe6e7
@tablatronix commented on GitHub (Mar 4, 2018):
there is no wifiserver constructor for this
_server(addr, port)so it takes the addr as port.
@jwktje commented on GitHub (Mar 4, 2018):
Just tried exactly what you put in the gist this but still the problem remains. The server keeps giving ERR_CONNECTION_REFUSED just after configuring the wifi. And after a reset it does handle routes fine. Obviously this was tested with
wifiManager.resetSettings()commented out as otherwise a manual reset would remove the credentials so it could never work.Anything else I could test? I don't even mind paying a small bug bounty for this or something? Would be awesome to get this patched.
@tablatronix commented on GitHub (Mar 5, 2018):
You used the gist verbatim?
@tablatronix commented on GitHub (Mar 5, 2018):
Do me a favor, port scan your esp. what os are you on i can tell you how
@jwktje commented on GitHub (Mar 5, 2018):
Just did a portscan on osx. This is the result:
I will try and start the server on a different port than 80 in the reset call. Just to see if it does spin up then.
Update:
Yep that works. Just changed the reset call to this:
server.reset(new WebServer(3000));Then the portscan result is this:
Does this mean I'm "doomed" to run my server on any port except 80?
@tablatronix commented on GitHub (Mar 5, 2018):
I am assuming you port scanned it after "HTTP Started"
Yeah that is very strange..
I may test some more.
@jwktje commented on GitHub (Mar 5, 2018):
Yep, but that does only get logged during the capacitive portal phase like so
*WM: HTTP server startedThere is no HTTP started logged afterwards when resetting my server.
When I port scan on the AP ip when connected to it's own AP network I get the following, as expected:
@tablatronix commented on GitHub (Mar 5, 2018):
The gist says
"Serial.println("HTTP server started");"
Did you pull in the latest commits?
@jwktje commented on GitHub (Mar 5, 2018):
Yes I tested that first and then went back to my own sketch for testing. But the relevant calls are identical in order. Just to be sure, I ran the gist again. This is the log
Portscan results are as I explained before. I get port 80 when connected to the AP. And it finds nothing after connecting.
Anything else I can help to test? I did pull the latest commits yesterday from the Development branch
@tablatronix commented on GitHub (Mar 5, 2018):
I will try to test again on my side, because it was working for me before, I do not have a working ap at the moment, so it might take a bit. For some reason esp32 doesn't see my hotspot like esp8266 does.
@tablatronix commented on GitHub (Mar 5, 2018):
were you also running the core dnsserver?
@tablatronix commented on GitHub (Mar 6, 2018):
Still no reproduce, even on port 80.
works for me, on captive portal save, and autoconnect success.
I added a 1 second delay before server.reset, not sure if that increased stability or not.
this helps testing also
personally I would destroy the wifimanager instance before starting the webserver, unless your code needs it to stick around, at least stopWebPortal()
@jwktje commented on GitHub (Mar 6, 2018):
Nope I just checked and I was using bbx10/DNSServer_tng as the DNS server. This might be the problem? I will check again with the core one. I remember needing the bbx10 DNS server as tipped in an issue a while back. But maybe core is stable enough now for esp32.
Will report back soon! (tonight probably)
@tablatronix commented on GitHub (Mar 6, 2018):
I doubt it, dnsserver was just updated in core yesterday. Just making sure I am on the same page.
@jwktje commented on GitHub (Mar 6, 2018):
Could this just be a flaw in the ESP32 chip with this setup though? I just tested again with the latest commits for WiFiManager and nothing but the core libs and the bbx10 webserver. Both my code and your Gist, but no luck.
@jwktje commented on GitHub (Mar 6, 2018):
Wow wow wow wait. Just tested without explicitly including the WebServer.h and now it looks like it's working. I only commented out like so
#include <WebServer.h>. Maybe the ESP32 arduino environment now has a more stable WebServer?Update:
And now it randomly doesn't anymore. :( No rhyme or reason
Another update:
It now seems to work shakily but it is an improvement. After resetting and repeating the setup process via WifiManager about 20 times, I get ~75% success rate on finding port 80 after a portscan.
I don't know how to further improve now as this makes it even more fuzzy for me to pinpoint the reason for this.
Third update:
Obviously by uncommenting the line for WebServer.h my sketch is probably including ESP8266WebServer as that's defined in WiFiManager right? Maybe this is causing the difference in results I'm seeing?
@tablatronix commented on GitHub (Mar 6, 2018):
That would not matter wm includes the webserver, there is no webserver in esp32 at all.
How exactly are you testing this ? Wipe settings, connecting to ap, saveing, then trying to connect to your webserver and it fails ?
Did you try enabling debug flag -DDEBUG_ESP_HTTP_SERVER and see what happens?
@jwktje commented on GitHub (Mar 6, 2018):
Yep exactly that is how I've been testing for the last hour. I will try the debug flag now and continue testing.
Update:
Using the Arduino IDE I can only set "Verbose" debugging at max. Will test some more though
@jwktje commented on GitHub (Mar 6, 2018):
I'm now getting the logs below with verbose debugging. It shows the AP_STOP event after I'm trying to reset my WebServer. Maybe this could be causing trouble?
@tablatronix commented on GitHub (Mar 6, 2018):
did you ever add that delay I mentioned?
@jwktje commented on GitHub (Mar 6, 2018):
Yep that's in my sketch. It is the only relevant change I made which is now causing it to work a majority of the times. As I now realize that uncommenting the WebServer library makes no difference.
Should I just increase it to a crazy amount of seconds and check my mileage?
@tablatronix commented on GitHub (Mar 7, 2018):
I just started getting crashes on my esp32 with this code for some reason.
I had to remove this
whats more interesting is this
@jwktje commented on GitHub (Mar 7, 2018):
Hmm. Well, I am a webdeveloper first, and Arduino enthusiast second. So maybe I'm misunderstanding.
But does this indicate just instability in the Arduino Core from espressif? I mean, random Exceptions/crashes when using function as they are intended. Isn't that just a result of core bugs?
@tablatronix commented on GitHub (Mar 7, 2018):
it goes away when changing various pieces of code, so its probably unrelated, maybe a compiler bug
@tablatronix commented on GitHub (Mar 14, 2018):
I posted this to esp32 lib, still no response
@andrewjaykeller commented on GitHub (Apr 7, 2018):
is my issue of not being able to run wifiManager at the same time as a WebServer on port 80 related to this? I tried doing a server.stop() but that does not seem to help.
@tablatronix commented on GitHub (Apr 7, 2018):
no
@andrewjaykeller commented on GitHub (Apr 7, 2018):
Should I open another issue for that?
@tablatronix commented on GitHub (Apr 7, 2018):
There are already issues discussing the exact same thing, you cant run 2 webservers ...
@tablatronix commented on GitHub (Apr 7, 2018):
Maybe make a simple sketch and paste it?
@tablatronix commented on GitHub (Apr 7, 2018):
Did you test my gist?
@andrewjaykeller commented on GitHub (Apr 8, 2018):
@tablatronix hi!
I just ripped out all the unneeded code to make a simple example!
https://github.com/PushTheWorld/OpenBCI_Air_Shield_Library/blob/esp32/examples/ESP32WiFiManager/EPS32WiFiManager.ino
You can see see in line 243 where there is a lambda function call on a server route to start the wifi manager (a flag is set true, 200 response sent to client) then later in loop the wifi manager is started.
@tablatronix commented on GitHub (Apr 8, 2018):
Hmm similar error here #585 but esp8266
@anwarbashir commented on GitHub (Jun 15, 2018):
Hi, I am using Platform.IO with development version of WifiManager (tzapu) and WebServer (bbx10). I am exclusively using ESP32. I am able to obtain a WiFi connection, but after accessing via AP the WiFi on my phone does not revert and I have to reset it manually. This is okay but a bit cumbersome. I think on the ESP8266 it reverts automatically. I think that the reason for this behaviour is down to a {ERROR} disconnect configportal - softAPdisconnect FAILED (But I may be wrong)? In any case can someone advise me, is it possible for the phone to reconnect to WiFi afterwards automatically and if so what can I do to enable this functionality. The console log is provided below:
--- Miniterm on COM5 9600,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
b����␂␄ ␃�␗␙�$�d'�␀3v�E (20370) wifi: esp_wifi_disconnect 847 wifi not start
*WM: Disabling STA
*WM: Enabling AP
*WM: StartAP with SSID: thing2car
*WM: AP has anonymous access!
*WM: AP IP address: 192.168.4.1
*WM: Starting Web Portal
*WM: HTTP server started
*WM: WiFi Scan done
*WM: Config Portal Running, blocking, waiting for clients...
*WM: NUM CLIENTS: 1
*WM: <- HTTP Wifi
*WM: Scan is cached
*WM: 4 networks found
*WM: DUP AP: Virgin Media
*WM: AP: -45 VM575052-2G
*WM: AP: -45 Virgin Media
*WM: AP: -93 VM2135198
*WM: <- HTTP WiFi save
*WM: process connect
*WM: Connecting as wifi client...
*WM: Connecting to new AP: VM575052-2G
*WM: connectTimeout not set, ESP waitForConnectResult...
*WM: Connection result: WL_CONNECTED
*WM: Connect to new AP [SUCCESS]
*WM: Got IP Address:
*WM: 192.168.0.11
*WM: disconnect configportal
*WM: [ERROR] disconnect configportal - softAPdisconnect FAILED
*WM: config portal exiting
connected...yeey
Attempting MQTT connection...connected
@tablatronix commented on GitHub (Jun 15, 2018):
When was the last time you pulled in esp32 lib ?
@anwarbashir commented on GitHub (Jun 16, 2018):
@tablatronix - it was some time ago, seems from your comment that I need the latest, so I will look at how to download and install the latest. If you could advise a link that would be useful - thanks.
@tablatronix commented on GitHub (Jun 16, 2018):
I have no idea what environment you are using but you get it from github.
@anwarbashir commented on GitHub (Jun 16, 2018):
@tablatronix I am using Platform.IO. Thanks to your comment I checked the Platform Version shown on Platforms in IDE it was Espressif 32 version 0.12.0 and showing that an update was available to 1.0.2. I upgraded and, subject to further testing, this seems to have worked. Many, many thanks :)
@UroojAlam commented on GitHub (Jun 16, 2020):
For me, changing the web server port to 81 and 8080 without using
wifiManager.resetSetting();worked.