最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

arduino - ESP32 send HTTP header failed after a 200 OK - Stack Overflow

programmeradmin0浏览0评论

I'm recently working on an Arduino project that requires using HTTP requests.

The following is my code

sender.begin(dataServer);
    sender.addHeader("Content-Type", "application/json; charset=UTF-8"); 
    while (true) {
        if (sendSignal) {
            sendData["id"] = StationID;
            Serial.println("sending");
            String sendString;
            serializeJson(sendData, sendString);
            Serial.println(sendString);
            int code = sender.POST(sendString);
            sender.end(); // AI suggests to put it in
            Serial.println(code);
            sendSignal = false;
            blinkState = !blinkState;
            digitalWrite(LED_BUILTIN, blinkState);
        }

The problem was: everytime, the request after a 200 ok request always shows -2(HTTPC_ERROR_SEND_HEADER_FAILED)

I tried asking AI but none of their suggestions worked.

I hope that there's no failure sending the request.

Can anyone help with this problem? Thanks.

发布评论

评论列表(0)

  1. 暂无评论