Page 1 of 1

[solved] WebServer (dual AP/STA multi-home) demo code does not work?

Posted: Sun Oct 29, 2023 10:07 pm
by qubdtq
Hello -- I am trying the demo code found here to create webservers that respond on the STA mode wifi connection, the soft AP, or both.

It seems to work fine: I can connect to the soft AP or my local network, and the terminal output does not show any errors.

When I connect via my local wifi network (i.e. "STA" mode or what the code calls the "WLAN" server) it works fine: :80 shows server0, and :8081 shows the WLAN server (server1).

But when I am connected to the soft AP, I cannot get any response from the webserver (server2) -- connections just time out.

I am using an ESP32-DevKitC-VIE v4 (which uses a ESP32-WROVER-IE module). Vscode + platformIO.

Any advice? Thanks!

Terminal output:

Code: Select all

Multi-homed Servers example starting
Connecting ..
Connected to "mynetwork", IP address: "192.168.3.143
Soft AP SSID: "ESP32", IP address: 192.168.4.1
MDNS responder started
HTTP server0 started
HTTP server1 started
HTTP server2 started
SSID: mynetwork
        http://192.168.3.143:8080
        http://192.168.3.143:8081
SSID: ESP32
        http://192.168.4.1:8080
        http://192.168.4.1:8081
Any of the above SSIDs
        http://esp32.local:8080
        http://esp32.local:8081

Re: WebServer (dual AP/STA multi-home) demo code does not work?

Posted: Sun Oct 29, 2023 10:32 pm
by lbernstone
When you are connected to the AP, can you ping the device (at 192.168.4.1)?
Try setting WiFi.setSleep(false); to disable modem sleep, which can cause you to miss requests.

Re: WebServer (dual AP/STA multi-home) demo code does not work?

Posted: Sun Oct 29, 2023 11:33 pm
by qubdtq
Thanks! -- there is no response from ping at 192.168.4.1 (it does respond when connected to shared WLAN and pinging to 192.168.3.143). I tried WiFi.setSleep(false); (right after WiFi.begin()) but it had no effect.

Edit to add: doing a port scan (1-9000) on 192.168.3.143 shows 8080 and 8081, doing it for 192.168.4.1 while connected to soft AP shows nothing.

Re: WebServer (dual AP/STA multi-home) demo code does not work?

Posted: Mon Oct 30, 2023 4:45 pm
by lbernstone
This sounds like a client issue, so I'm going to assume you are using Windows.
There is nothing blocking you from pinging on the esp32 side, so check your firewall and network settings to make sure Windows hasn't decided what is best to keep you safe.

Re: WebServer (dual AP/STA multi-home) demo code does not work?

Posted: Mon Oct 30, 2023 5:17 pm
by qubdtq
Thanks for the ideas -- my computer is linux but I'm testing the AP connection with my android phone. (Ping tests using app "pingtools").

Via the STA server I can ping over the shared WLAN (using the phone) to the IP of the STA server and see 80, 8080, whatever it's set to, web pages work fine, etc. It's only when connected to the AP network that I can't get anything. Doesn't matter if I use MDNS or direct IP. Doesn't matter if I let the AP IP be chosen or set it manually.

I have also tried a variety of AP-only tutorials for webservers out there like this one and this one and this one (using WiFiServer, ESPAsyncServer, and WebServer, respectively) but nothing seems to work.

Re: WebServer (dual AP/STA multi-home) demo code does not work?

Posted: Mon Oct 30, 2023 5:50 pm
by qubdtq
^&#$%#, you were right, it was PEBCAK. Well, it was the phone's fault, anyway. :-)

When I connect to the AP the phone says "myesp32net has no internet access - tap for options". I was dismissing that notification because of course there is no internet access -- doesn't matter. The phone stays connected to the AP without issue, as expected, but it just fails silently when you try to do anything. If you open that notification it says "do you want to stay connected to this AP even though it has no internet access" and you say "yes", then everything works as expected.

Weird things: I've never had to do this for other AP devices I connect to that also don't provide internet access. Also, when I was first testing this stuff, I was able to connect over the AP route (without STA active) and I never went into that notification (this was the first time I've ever even looked at it.)

At any rate, chalk it up to "dumb phone OS / user" and sorry for the waste of time. Thanks for the assistance!