ESP32 Wifi not working though Wifi Extender

Got an odd issue I hope someone has some advice on.

I have a server in the house running a Flask WebAPI which can accept POST’ed data. I also have a DFRobot FireBeetle ESP32 which deep sleeps, wakes, takes readings, connects to WIFI, POSTs the data to the server and goes back to sleep again. Fairly simple stuff.

When I connect the ESP32 into the same network as the server, everything works fine. The POSTs take milliseconds. However that WIFI network is not available where I want the sensor. I I have one of those external WIFI extenders which reaches where I want the sensor.

I can connect through the extender with my phone and that works fine, but the ESP32 will connect successfully to the WIFI network (and get a valid IP address on that network) but POSTs to the server fail. Sometimes with “read timed out” sometimes with “software caused connection to abort”. I tried manually setting the ip/gateway/default route etc but it made no difference. I tired changing the timeouts but it just takes longer to report the error.

Code on the ESP BTW is written in C++ on PlaformIO using Arduino style libs.

Any suggestions?

Thanks
S.

But did you also test that you can make POST requests to your server through your phone / or view the website?

As a general measure you can collect more data about this issue by increasing the log level on the ESP32 side to ‘verbose’: Espressif 32 — PlatformIO latest documentation

Does the code have hardcoded read timeouts that are really too small for that network configuration?

Good point. Will try POSTing from an app on my phone.

Thanks for the debug link - I was looking for this and couldn’t find it.

Timeouts set to 30 seconds.

S.

So a POST works fine from a REST client on my phone.

Setting debug level shows the following output…

[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 0 - WIFI_READY
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 2 - STA_START
Connecting to WiFi…
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:419] _eventCallback(): STA IP: 192.168.10.100, MASK: 192.168.10.1, GW: 192.168.0.1
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:419] _eventCallback(): STA IP: 192.168.10.100, MASK: 192.168.10.1, GW: 192.168.0.1
Connected, IP address: 192.168.10.100
POSTING to http://192.168.0.23:5555/api/record : “temperature” : 16.25, “humidity” : 52.04, “temperature2” : 16.70, “pressure” : 1009.39
[V][HTTPClient.cpp:239] beginInternal(): url: http://192.168.0.23:5555/api/record
[D][HTTPClient.cpp:287] beginInternal(): host: 192.168.0.23 port: 5555 url: /api/record
POSTing…[D][HTTPClient.cpp:573] sendRequest(): request type: ‘POST’ redirCount: 0

[E][WiFiClient.cpp:258] connect(): socket error on fd 54, errno: 113, “Software caused connection abort”
[D][HTTPClient.cpp:1112] connect(): failed connect to 192.168.0.23:5555
[W][HTTPClient.cpp:1411] returnError(): error(-1): connection refused
POST FAILED to http://192.168.0.23:5555/api/record
connection refused
[D][HTTPClient.cpp:394] disconnect(): tcp is closed

The mask it’s getting looks odd - MASK: 192.168.10.1. I would have expected 255.255.255.0

I tried disabling IPV6 on the server, but that made no difference.

Apart from the the logs are just showing socket error on fd 54, errno: 113, “Software caused connection abort”.

S.

Indeed weird – I’d also expect the mask to be more 255.255.255.0 and also the gateway to be on the same subnet as the the IP that the station (STA) has gotten, but it’s on 192.168.0.x instead of 192.168.10.x… Maybe this is right though for that special WiFi extender case. Looking at GitHub - martin-ger/esp_wifi_repeater: A full functional WiFi Repeater (correctly: a WiFi NAT Router) though this seems to be very similiar in mask and gateway.

You can also cross-check what IP, subnet and GW you have when connecting via the phone (at least in Android I can see that very easily in the WiFi settings).

Still if your phone can do it and the ESP32 can not then there’s maybe a misconfiguration in the lower-level WiFi / TCP stacks of the framework that don’t allow for this WiFi extender scenario. You shuld ask directly at Issues · espressif/arduino-esp32 · GitHub for that.

Indeed I think it’s wrong. My phone when connected to that WiFi says Gateway 192.168.10.1 with Subnet mask of 255.255.255.0.

I will try and see about changing this (I did try and give the correct mask earlier but it ignored the setting) and see if that has any more success.

Thanks
S.