Skip to content

Httpclient causing ESP32 to panic in versions V1.0.3 & V1.0.4 #4039

Closed
@chaplijt

Description

@chaplijt

I had been running Arduino core for ESP32 V1.0.2 and programs on WEMOS LOLIN & ESP32 DEV Board (EzSBC brand) were working as intended. There was a reminder of board & library updates ,from Arduino , so I updated. To ESP32 V1.0.4 and started getting random panic'd errors which were very frustrating. Investigation suggested that http.end() was the culprit. Went back to basics and tried the example sketch for httpclient basic (below modified for my wifi & target URL). IT also panic'd.

Downloaded esptools & erased flash. that did not remedy situation. Going back to V1.0.2 did correct it.

CODE:
/**

  • BasicHTTPClient.ino
  • Created on: 24.05.2015

*/

#include <Arduino.h>
#include <credentials.h>
#include <WiFi.h>
#include <WiFiMulti.h>

#include <HTTPClient.h>

#define USE_SERIAL Serial

WiFiMulti wifiMulti;

const char* ssid = mySSID;
const char* password = myPASSWORD;

void setup() {

USE_SERIAL.begin(115200);
USE_SERIAL.println();

for(uint8_t t = 4; t > 0; t--) {
    USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
    USE_SERIAL.flush();
    delay(1000);
}

wifiMulti.addAP(ssid, password);

}

void loop() {
// wait for WiFi connection
if((wifiMulti.run() == WL_CONNECTED)) {

    HTTPClient http;

    USE_SERIAL.print("[HTTP] begin...\n");
    // configure traged server and url
    //http.begin("https://www.howsmyssl.com/a/check", ca); //HTTPS
    http.begin("http://192.168.2.115/data"); //HTTP

    USE_SERIAL.print("[HTTP] GET...\n");
    // start connection and send HTTP header
    int httpCode = http.GET();

    // httpCode will be negative on error
    if(httpCode > 0) {
        // HTTP header has been send and Server response header has been handled
        USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);

        // file found at server
        if(httpCode == HTTP_CODE_OK) {
            String payload = http.getString();
            USE_SERIAL.println(payload);
        }
    } else {
        USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
    }

    http.end();
}

delay(5000);

}

typical serial monitor when working (V1.0.2)
HTTP] begin...
[V][HTTPClient.cpp:224] beginInternal(): url: http://192.168.2.115/data
[D][HTTPClient.cpp:265] beginInternal(): host: 192.168.2.115 port: 80 url: /data
[D][HTTPClient.cpp:1002] connect(): connected to 192.168.2.115:80
[V][HTTPClient.cpp:1097] handleHeaderResponse(): RX: 'HTTP/1.1 200 OK'
[V][HTTPClient.cpp:1097] handleHeaderResponse(): RX: 'Content-Type: text/plain'
[V][HTTPClient.cpp:1097] handleHeaderResponse(): RX: 'Content-Length: 27'
[V][HTTPClient.cpp:1097] handleHeaderResponse(): RX: 'Connection: close'
[V][HTTPClient.cpp:1097] handleHeaderResponse(): RX: ''
[D][HTTPClient.cpp:1127] handleHeaderResponse(): code: 200
[D][HTTPClient.cpp:1130] handleHeaderResponse(): size: 27
[D][HTTPClient.cpp:1264] writeToStreamDataBlock(): connection closed or file end (written: 27).
[D][HTTPClient.cpp:358] disconnect(): tcp stop

data$1$$0353$$$00716$$$$end
[D][HTTPClient.cpp:369] disconnect(): tcp is closed

Note: when running with supplied external URL worked on both releases. However, when pointing to my ESP32 server at home network URL, panic ensued. Server response string is in form of
data$1$$0353$$$00716$$$$end
where numbers change to reflect solar generation

the panic result when using V1.0.4 decoded to:
Guru Meditation Error: Core 1 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x00000000 PS : 0x00060430 A0 : 0x800d391e A1 : 0x3ffb1e90
A2 : 0x3ffb1f10 A3 : 0x00000000 A4 : 0x0000001b A5 : 0x0000001b
A6 : 0x3ffcc0ec A7 : 0x0000001b A8 : 0x8015d45a A9 : 0x3ffb1e70
A10 : 0x3ffbbca0 A11 : 0x00000000 A12 : 0x00000002 A13 : 0x0000ff00
A14 : 0x00ff0000 A15 : 0xff000000 SAR : 0x0000000a EXCCAUSE: 0x00000014
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff

Backtrace: 0x00000000:0x3ffb1e90 0x400d391b:0x3ffb1eb0 0x400d398d:0x3ffb1ed0 0x400d19db:0x3ffb1ef0 0x400d7475:0x3ffb1fb0 0x40088b9d:0x3ffb1fd0
PC: 0x00000000
EXCVADDR: 0x00000000

Decoding stack results
0x400d391b: HTTPClient::disconnect(bool) at C:\Users\john\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\HTTPClient\src\HTTPClient.cpp line 359
0x400d398d: HTTPClient::end() at C:\Users\john\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\HTTPClient\src\HTTPClient.cpp line 347
0x400d19db: loop() at C:\Users\john\Documents\Arduino\dehumid_rebuild/dehumid_rebuild.ino line 67
0x400d7475: loopTask(void*) at C:\Users\john\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32\main.cpp line 19
0x40088b9d: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143

I repeated this on two different esp32 boards, with 2 variants of program all resulting in same panic.

please advise

john

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions