Page 1 of 1

http server refuses connection

Posted: Wed Apr 26, 2023 8:48 pm
by pppTec
When I'm running my ESP32-S2 in Access Point (AP) mode with a fixed IP and the ESP IDF http server running, I am able to connect to the server (port 80). However, I made the application such that I can change to station mode (STA), stop the http server, restart the wifi and start the server again. After this, I'm unable to connect to the http server anymore.

When tracking the communication in Wireshark, I see that my PC is trying to establish the connection to ESP32, but it sends a RST, ACK flag in the TCP protocol, meaning the ESP32 is actively refusing the connection. When going back to AP mode (without resetting the device), it stays refusing the connection. After powering toggling or resetting the ESP32, I'm able to connect to ESP32 again in AP mode.

I checked my router to see if it blocks connections between devices, but running a local http server on my pc is accesible from my phone without problems, so this doesn't seem the issue. I think somewhere in the ESP32 software something is going wrong, but I cannot figure out what.

What am I doing wrong? Or what can I check?

Re: http server refuses connection

Posted: Thu Apr 27, 2023 10:03 pm
by mbratch
Maybe this post would be helpful: https://esp32.com/viewtopic.php?t=12879

Re: http server refuses connection

Posted: Fri Jun 16, 2023 8:10 am
by pppTec
There were different things going wrong in my code. It was easier to put the Wifi driver in APSTA mode. Then you can use Wifi connect / disconnect for connecting with the access point for station mode while the ESP32 soft AP remains active. Then running the http server will just work normally instead of switching actively between AP and STA mode.