http server refuses connection

pppTec
Posts: 4
Joined: Sun Apr 16, 2023 12:48 pm

http server refuses connection

Postby pppTec » Wed Apr 26, 2023 8:48 pm

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?

User avatar
mbratch
Posts: 300
Joined: Fri Jun 11, 2021 1:51 pm

Re: http server refuses connection

Postby mbratch » Thu Apr 27, 2023 10:03 pm

Maybe this post would be helpful: https://esp32.com/viewtopic.php?t=12879

pppTec
Posts: 4
Joined: Sun Apr 16, 2023 12:48 pm

Re: http server refuses connection

Postby pppTec » Fri Jun 16, 2023 8:10 am

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.

Who is online

Users browsing this forum: Bing [Bot] and 79 guests