When ESP8266HTTPClient calls a GET method which responds with HTTP code 500, ESP8266 NodeMCU board resets itself. GET request is created using mocky.io. However, Following code handles HTTP code 200 successfully.
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>
HTTPClient httpClient;
const char* ssid = "";
const char* wifiPassword = "";
int httpCode;
String payload;
String url = "http://run.mocky.io/v3/c8e3aee6-15ec-4c8c-a8d4-f709f95d17e2";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
WiFi.begin(ssid, wifiPassword);
while (WiFi.status() != WL_CONNECTED) {
Serial.println("Connecting to Wi-Fi...");
delay(500);
}
Serial.println("Connected to Wi-Fi network");
}
void loop() {
// put your main code here, to run repeatedly:
httpClient.begin(url);
httpCode = httpClient.GET();
payload = httpClient.getString();
httpClient.end();
Serial.println("delaying...");
delay(10000);
}
This is the decoded exception message.
Exception 28: LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads
PC: 0x40206e98: HTTPClient::connected() at C:\Users\Binod\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 475
EXCVADDR: 0x00000184
Decoding stack results
0x40203a34: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\Binod\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266/HardwareSerial.h line 164
0x40203d15: Print::write(char const*) at C:\Users\Binod\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266/Print.h line 62
0x4020127c: HTTPClient::disconnect(bool) at C:\Users\Binod\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 434
0x40202024: HTTPClient::end() at C:\Users\Binod\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 425
0x40201105: loop() at C:\Users\Binod\Documents\Arduino\sketch_jul28a/sketch_jul28a.ino line 32
0x40201088: setup() at C:\Users\Binod\Documents\Arduino\sketch_jul28a/sketch_jul28a.ino line 17
0x40205188: loop_wrapper() at C:\Users\Binod\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 197
User contributions licensed under CC BY-SA 3.0