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

qubdtq
Posts: 12
Joined: Thu Sep 21, 2023 3:41 am

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

Postby qubdtq » Sun Oct 29, 2023 10:07 pm

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
Last edited by qubdtq on Mon Oct 30, 2023 5:51 pm, edited 1 time in total.

lbernstone
Posts: 828
Joined: Mon Jul 22, 2019 3:20 pm

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

Postby lbernstone » Sun Oct 29, 2023 10:32 pm

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.

qubdtq
Posts: 12
Joined: Thu Sep 21, 2023 3:41 am

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

Postby qubdtq » Sun Oct 29, 2023 11:33 pm

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.

lbernstone
Posts: 828
Joined: Mon Jul 22, 2019 3:20 pm

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

Postby lbernstone » Mon Oct 30, 2023 4:45 pm

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.

qubdtq
Posts: 12
Joined: Thu Sep 21, 2023 3:41 am

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

Postby qubdtq » Mon Oct 30, 2023 5:17 pm

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.

qubdtq
Posts: 12
Joined: Thu Sep 21, 2023 3:41 am

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

Postby qubdtq » Mon Oct 30, 2023 5:50 pm

^&#$%#, 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!

Who is online

Users browsing this forum: No registered users and 118 guests