esp-idf: HTTP server will intermittently take 30 or more seconds to respond to an HTTP request (IDFGH-5608)

Environment

  • Development Kit: ESP32-PICO-Kit
  • Kit version (for WroverKit/PicoKit/DevKitC): v4.1
  • Module or chip used: ESP32-PICO-D4
  • IDF version (run git describe --tags to find it): 4.3
  • Build System: idf.py
  • Compiler version (run xtensa-esp32-elf-gcc --version to find it): 8.4.0
  • Operating System: WIndows 10
  • (Windows only) environment type: PowerShell
  • Using an IDE?: Yes (Eclipse)
  • Power Supply: USB

Problem Description

I have an HTTP REST server modeled after the rest server example provided by the ESP-IDF framework. When a REST API request is made, typically the request handler (registered with httpd_register_uri_handler) is called nearly immediately. However, there are many periods of time when the request handler is not called for 30 or more seconds after the HTTP request is sent over the network to the ESP32. The only other activity occurring in the ESP32 is a 500ms LED flash timer, and a 2 second LED status update timer, each of which takes very little time (as timer tasks should).

Expected Behavior

When an HTTP REST API request is sent to the ESP32 REST server, the ESP32 library code that receives the request and dispatches the handler should take a lot less than 30 seconds.

Actual Behavior

Sometimes the dispatching of the HTTP request handler takes in excess of 30 seconds.

Steps to reproduce

  1. Run ESP32 REST API code that is idle and awaiting REST API requests
  2. Send regular REST API requests to the ESP32 and observe prompt response (within a second or two) to the requests
  3. Observe occasional delay of up to 30 or more seconds in response to some REST API requests

Debug Logs

No messages appear on the monitor during the operation of this test.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 29 (11 by maintainers)

Most upvoted comments

@shubhamkulkarni97 I’ve been collecting data over many days. I have two ESP32 devices each running the same firmware except one of them has the wifi power saving turned off via esp_wifi_set_ps(WIFI_PS_NONE);. I have two scripts running on a Linux server, each sending an HTTP request every 2-3 seconds to its respective ESP32 device and I record the response time if it’s greater than 1 second. In the case where the power savings is default, I get numerous response delays per day that are > 30s and some > 60s. For the unit that has the power savings turned off, I have gotten several > 1s or maybe 2s, and one that was 16s. I’m puzzled as to why wifi power saving would affect this since I’m regularly interacting with the devices over wifi, so they shouldn’t be going into any kind of power save mode I wouldn’t think.

I did also run a test with just lru_purge_enable set to true on the interface but that didn’t seem to affect the result much.

@shubhamkulkarni97 I do not have any updates. I’ve been planning on using some of the suggested settings, but have been focusing on a more serious problem at the moment (#7286). For the HTTP response delay, it’s difficult to catch “live”. I will need to write a script so I can check timings and the effect of some of the suggested settings. Not too difficult, I just have to get to it.