Skip to content

async_handlers don't work as expected (stop working fine after first async request) (IDFGH-16734) #17821

@mattcarter11

Description

@mattcarter11

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

General issue report

  • IDF version → v5.5.1
  • SoC → ESP32-D0WD (revision v1.1) or ESP32-S3
  • OS → Windows
  • Build and flash → With the VSCode esp-idf extension
  • Power Supply → USB

What is the expected behavior?

To be able to do the same async request more than once

What is the actual behavior?

  1. The first async response works fine
  2. The consequent async responses don't work

Steps to reproduce.

  1. Clone the async_handler example
  2. Simplify the async for simple testing
static esp_err_t long_async(httpd_req_t* req) {
    ESP_LOGI(TAG, "Request URI: %s", req->uri);

    esp_err_t err = httpd_resp_sendstr_chunk(req, "test");
    if (err != ESP_OK) {
        ESP_LOGE(TAG, "Failed to send string chunk: %s", esp_err_to_name(err));
        return err;
    }

    err = httpd_resp_sendstr_chunk(req, NULL);
    if (err != ESP_OK) {
        ESP_LOGE(TAG, "Failed to send string chunk: %s", esp_err_to_name(err));
        return err;
    }

    return ESP_OK;
}
  1. Build and flash
  2. Try curl http://<ip>/long for time.
    • The first time you get a respone
    • The second you don't
    • The third you do and in the logs it seems to log both 2n and 3r
    • The forth gets again stuck
  3. Now restart and try curl http://<ip>/long then curl http://<ip>/quick
    • Quick gets stuck

Note

Adding httpd_resp_set_hdr(req, "Connection", "close"); seems to fix the problem partially. I found that in my API, if I also don't read the entire body of the POST/PUT request, they get stuck. I'll try replicating in a simple example

Update 1: the POST/PUT problem seems to happen on Windows with chrome/edge. On chrome Android the problem doesn't seem present

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions