ESP32, WiFi loopback: connected() not updated?

Sorry if this is misplaced here…

For testing I am using the loopback interface on the ESP32 (arduino-esp32 core). A server and a client are running in different tasks, the client connecting to the server. If the server disconnects, the client does not notice - the connected() call always will report the connection would be still established.

It took me a while to find that the client.connected() return value for the loopback connection seems to only be updated if an external connection from another client in the net is established or disconnected.

Is there any special treatment necessary, is it like that by design or am I completely wrong? I could not find any concise information about that yet.

Any idea, anyone? Or does no one use the loopback IF at all?

Never mind. I found my workaround.

I’m about to start playing with some ESP32 stuff. Would you be kind enough to post your workaround please, in case I hit similar problems? Thanks in advance.

Cheers,
Norm.

Well, the first attempt was nothing elegant, I am afraid. I had another MCU connecting and disconnecting regularly over the network :man_facepalming:
The current solution was surprising, at least for me: if you do a WiFi.begin("foo", "bar"); with no real ssid and password, you still can use the loopback on 127.0.0.1 and now it is working.

1 Like