Skip to content

Crash and reboot when reaching getString() method #6688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
6 tasks done
MateuszManaj opened this issue Oct 29, 2019 · 31 comments
Closed
6 tasks done

Crash and reboot when reaching getString() method #6688

MateuszManaj opened this issue Oct 29, 2019 · 31 comments

Comments

@MateuszManaj
Copy link

MateuszManaj commented Oct 29, 2019

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: [nodeMCU dev board rev3]
  • Core Version: 2.5.2 (from added logs)
  • Development Env: [Arduino IDE]
  • Operating System: [MacOS]

Settings in IDE

  • Module: [Nodemcu]
  • Flash Mode: [don't know]
  • Flash Size: [4MB]
  • lwip Variant: [v2 Lower Memory]
  • Reset Method: [nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [80Mhz]
  • Upload Using: [SERIAL]
  • Upload Speed: [115200] (serial upload only)

Problem Description

Board crashed when code reaching

String payload = http.getString();

Problem occurs when requesting GET from this host: http://192.168.8.218 - this is my stove webserver. For 1 month it was ok but now i cannot getting response. Other host working properly. I tried to change IP of webserver - nothing changed.

Tell me, what needs to happen for getString() method to crash and reboot board ?
In addtion, response from webserver is correct. All packets and whole response is ok.

MCVE Sketch

#include <Arduino.h>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

#include <ESP8266HTTPClient.h>

#include <WiFiClient.h>

ESP8266WiFiMulti WiFiMulti;

void setup() {

  Serial.begin(115200);
  // Serial.setDebugOutput(true);

  Serial.println();
  Serial.println();
  Serial.println();

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

  WiFi.mode(WIFI_STA);
  WiFiMulti.addAP("ABC", "DEF");

}

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

    WiFiClient client;

    HTTPClient http;

    Serial.print("[HTTP] begin...\n");
    if (http.begin(client, "http://192.168.8.218")) {  // HTTP


      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
        Serial.printf("[HTTP] GET... code: %d\n", httpCode);

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

      http.end();
    } else {
      Serial.printf("[HTTP} Unable to connect\n");
    }
  }

  delay(10000);
}

Debug Messages

Decoding stack results
0x4021850c: mem_malloc at core/mem.c line 210
0x40206e3c: malloc(size_t) at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/umm_malloc/umm_malloc.cpp line 1677
0x40210fac: lwip_cyclic_timer at core/timeouts.c line 233
0x4021850c: mem_malloc at core/mem.c line 210
0x4020f8e8: do_memp_malloc_pool at core/memp.c line 254
0x4020f924: memp_malloc at core/memp.c line 356
0x40210f51: sys_timeout_abs at core/timeouts.c line 189
0x40210fac: lwip_cyclic_timer at core/timeouts.c line 233
0x40210fdf: lwip_cyclic_timer at core/timeouts.c line 261
0x4020f94e: memp_free at core/memp.c line 447
0x40211154: sys_check_timeouts at core/timeouts.c line 390
0x4020551f: loop_task(ETSEvent*) at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/core_esp8266_main.cpp line 133
0x4020f221: glue2esp_linkoutput at glue-esp/lwip-esp.c line 299
0x4020f4a3: new_linkoutput at glue-lwip/lwip-git.c line 235
0x4020f894: ethernet_output at netif/ethernet.c line 312
0x4021702c: etharp_output_LWIP2 at core/ipv4/etharp.c line 885
0x4020555a: esp_yield() at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/core_esp8266_main.cpp line 88
0x40213dfd: tcp_output_alloc_header at core/tcp_out.c line 1863
0x40214750: tcp_send_empty_ack at core/tcp_out.c line 2057
0x4021483e: tcp_output at core/tcp_out.c line 1319
0x402046c4: String::copy(char const*, unsigned int) at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/WString.cpp line 211
0x40205564: esp_yield() at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/core_esp8266_main.cpp line 91
0x40205564: esp_yield() at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/core_esp8266_main.cpp line 91
0x40205646: __yield() at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/core_esp8266_main.cpp line 100
0x4020430d: Stream::timedRead() at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/Stream.cpp line 37
0x4020434b: Stream::readBytes(char*, unsigned int) at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/Stream.cpp line 211
0x40207380: Stream::readBytes(unsigned char*, unsigned int) at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/Stream.h line 92
0x40203528: HTTPClient::writeToStreamDataBlock(Stream*, int) at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp line 1376
0x402035b0: HTTPClient::writeToStream(Stream*) at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp line 925
0x40204704: String::String(char const*) at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/WString.cpp line 36
0x40203d7e: HTTPClient::getString() at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp line 1010
0x4020117f: loop() at /Users/mateuszmanaj/Documents/Arduino/BasicHttpClient/BasicHttpClient.ino line 62
0x402018ac: ESP8266WiFiMulti::addAP(char const*, char const*) at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp line 39
0x40205614: loop_wrapper() at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/cores/esp8266/core_esp8266_main.cpp line 125
@devyte
Copy link
Collaborator

devyte commented Oct 29, 2019

[] If there is a stack dump, I have decoded it.

Why isn't the stack decoded? Please decode it and add it above.

@MateuszManaj
Copy link
Author

I do not know how :)

@devyte
Copy link
Collaborator

devyte commented Oct 29, 2019

Just google "decode esp8266 stack". Also, readthedocs.

@MateuszManaj
Copy link
Author

Ok, thank you. I edited issue. Is this memory leak ?

@devyte
Copy link
Collaborator

devyte commented Oct 29, 2019

You said:

[x] I have tested that the issue is present in current master branch (aka latest git).

But from your stack dump, you're using core v2.5.2.

Retesting with latest git is needed before this can be looked at further, because there have been several issues fixed, including interrupt and String issues. In other words, it makes no sense to look at this if the issue is already fixed in the latest code base.

Instructions for installing latest git are in readthedocs.

I am closing for now. If you find more information, please post it here and we can continue to discuss.

@devyte devyte closed this as completed Oct 29, 2019
@MateuszManaj
Copy link
Author

@devyte ok, thank you for instructions.
I've updated already ESP8266 lib and there is my another decoded exception stack:

Decoding stack results
0x40217314: ip4_output_if_opt_src at core/ipv4/ip4.c line 1764
0x401008e8: malloc(size_t) at /Users/mateuszmanaj/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/umm_malloc/umm_malloc.cpp line 511
0x40217e10: mem_malloc at core/mem.c line 210
0x40211d54: pbuf_alloc_LWIP2 at core/pbuf.c line 284
0x40212805: tcp_output_alloc_header_common at core/tcp_out.c line 1825
0x402128c9: tcp_output_alloc_header at core/tcp_out.c line 1863
0x402131f2: tcp_send_empty_ack at core/tcp_out.c line 2042
0x4021330a: tcp_output at core/tcp_out.c line 1319
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at /Users/mateuszmanaj/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_main.cpp line 156
0x4020e57d: tcp_recved at core/tcp.c line 1003
0x40202ba4: ClientContext::_consume(unsigned int) at /Users/mateuszmanaj/Documents/Arduino/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/include/ClientContext.h line 556
0x40202c1a: WiFiClient::read() at /Users/mateuszmanaj/Documents/Arduino/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/include/ClientContext.h line 239
0x402047fc: Stream::timedRead() at /Users/mateuszmanaj/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/Stream.cpp line 34
0x4020484b: Stream::readBytes(char*, unsigned int) at /Users/mateuszmanaj/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/Stream.cpp line 215
0x40207590: Stream::readBytes(unsigned char*, unsigned int) at /Users/mateuszmanaj/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/Stream.h line 92
0x4020373c: HTTPClient::writeToStreamDataBlock(Stream*, int) at /Users/mateuszmanaj/Documents/Arduino/hardware/esp8266com/esp8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp line 1401
0x4020416f: HTTPClient::sendRequest(char const*, unsigned char*, unsigned int) at /Users/mateuszmanaj/Documents/Arduino/hardware/esp8266com/esp8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp line 725
0x402037be: HTTPClient::writeToStream(Stream*) at /Users/mateuszmanaj/Documents/Arduino/hardware/esp8266com/esp8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp line 934
0x40204262: HTTPClient::getString() at /Users/mateuszmanaj/Documents/Arduino/hardware/esp8266com/esp8266/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp line 1019
0x40201180: loop() at /Users/mateuszmanaj/Documents/Arduino/BasicHttpClient/BasicHttpClient.ino line 62
0x40201abb: std::vector   >::_M_emplace_back_aux (WifiAPEntry const&) at /Users/mateuszmanaj/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9/xtensa-lx106-elf/include/c++/4.8.2/ext/new_allocator.h line 104
0x40201bc0: ESP8266WiFiMulti::addAP(char const*, char const*) at /Users/mateuszmanaj/Documents/Arduino/hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp line 39
0x40205c90: loop_wrapper() at /Users/mateuszmanaj/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_main.cpp line 176

Can you help me with this ?

@devyte
Copy link
Collaborator

devyte commented Oct 30, 2019

How big is the resource you're trying to GET?

@MateuszManaj
Copy link
Author

MateuszManaj commented Oct 30, 2019

It's very small ~25kb

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
	<meta HTTP-EQUIV="content-type" content="text/html; charset=utf-8" />
	<meta HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
	<meta name="handheldFriendly" content="true" />              
	<meta name="viewport" content="width=device-width; initial-scale=1"; user-scalable="yes" />
	
	<title>MultiFun Control System</title>
	<link ID="styl_id" rel="stylesheet" type="text/css" media="screen"/> <!--href="style.css"-->
	<script language="javascript">
		var szer = window.screen.width;
		if(navigator.userAgent.indexOf('Opera Mini') > -1)
		{
			if(szer <= 1024){ document.getElementById('styl_id').href = "opmini.css"; }
			else{ document.getElementById('styl_id').href = "style.css"; }
		}
		else
		{
			if(szer <= 800) {document.getElementById('styl_id').href = "styleh.css"; }
			else if(szer <= 1024){document.getElementById('styl_id').href = "style600.css";}
			else{document.getElementById('styl_id').href = "style.css";}
		}
	</script>
</head>
<body>
	<div id="glowny">
		<div id="obrazek">
			<div id="ziel"><h1 class="green">MultiFun Control System</h1></div>
			<!--temperatury od róry-->
			<!--spaliny-->
			<div id="spaliny"><h1 class="black">32</h1></div>
			<!--zewnętrzna-->
			<div id="zewnetrzna"><h1 style="font-size: 42px;" class="blue"></h1></div>
			<!--pokojowa1-->
			<div id="pokojowa1"><h1 class="cherry"></h1></div>
			<!--pokojowa2-->
			<div id="pokojowa2"><h1 class="cherry"></h1></div>
			<!--CO1-->
			<div id="CO1"><h1 class="red">23</h1></div>
			<!--CO2-->
			<div id="CO2"><h1 class="red">26</h1></div>
			<!--Kocioł-->
			<div id="kociol"><h1 class="red">34</h1></div>
			<!--CWU-->
			<div id="CWU"><h1 class="red">37</h1></div>
			<!--Wyliczone-->
			<!--Pokój 1-->
			<div id="pokoj1"><h2></h2></div>
			<!--Pokój 2-->
			<div id="pokoj2"><h2></h2></div>
			<!--CO 1-->
			<div id="WCO1"><h2>20</h2></div>
			<!--CO 2-->
			<div id="WCO2"><h2></h2></div>
			<!--Kotla-->
			<div id="WKOC"><h2>0</h2></div>
			<!--CWU-->
			<div id="WCWU"><h2>0</h2></div>
			<form method="get" action="/opts.cgi">
				<div id="th1"><input type="text" name="TH1" size="4" value="35"></div>
				<div id="th2"><input type="text" name="TH2" size="4" value=""></div>
				<div id="th3"><input type="text" name="TH3" size="4" value="45"></div>
				<div id="op1"><input value="1" name="op" type="checkbox"></div>
				<div id="op2"><input value="2" name="op" type="checkbox"></div>
				<div id="op3"><input value="3" name="op" type="checkbox"></div>
				<div id="op4"><input value="4" name="op" type="checkbox"></div>
				<div id="op5"><input value="5" name="op" type="checkbox"></div>
				<div id="pas"><input name="pass" size="4" type="password"></div>
				<div id="but"><input value="OK" type="submit"></div>
			</form>
		</div>
	</div>
</body>
</html>

@MateuszManaj
Copy link
Author

I must add that this module works perfectly for about 2-3 months and suddenly stopped working (of course on previous git version of board). I tested this code on other same nodeMCU's but nothing change. This is very strange.
The only thing could change is my stove webserver but i do not see any strange notation or differencies. Also head od this document is ok. There is no special signs in code and encoding is UTF-8 wo. BOM.

@devyte
Copy link
Collaborator

devyte commented Oct 30, 2019

25KB is most definitely NOT very small, it's about half the total amount of available heap of an empty sketch, and yours is not an empty sketch.
My guess is you're oom. Please check available heap right before the call to getString().

@MateuszManaj
Copy link
Author

25KB is most definitely NOT very small, it's about half the total amount of available heap of an empty sketch, and yours is not an empty sketch.
My guess is you're oom. Please check available heap right before the call to getString().

Sorry, it's 2.9 - 3.1 kb.
What OOM stands for ?

@MateuszManaj
Copy link
Author

Ok, I have Exception 3 which stands for: LoadStoreErrorCause
Processor internal physical address or data error during load or store
Free heap before getString() is: 50864

@devyte
Copy link
Collaborator

devyte commented Oct 30, 2019

3KB should be ok, then I don't think it's oom (out of memory).
I think the only thing missing are the headers sent with your resource. Can you figure out how to get them and post them here? I think that should be enough info for someone to investigate.

@MateuszManaj
Copy link
Author

Response Headers:

HTTP/1.0 200 OK
Server: lwIP/1.3.1 (http://savannah.nongnu.org/projects/lwip)
Content-type: text/html
Expires: Fri, 10 Apr 2008 14:00:00 GMT
Pragma: no-cache

Maybe you reopen this issue ?

@MateuszManaj
Copy link
Author

@devyte Can you reopen this issue ?

@devyte devyte reopened this Oct 30, 2019
@MateuszManaj
Copy link
Author

@devyte thank you

@devyte
Copy link
Collaborator

devyte commented Oct 30, 2019

Just to be clear, you did install latest git following the instructions in readthedocs, right? And not some copy-over-2.5.2 folders or other install weirdness?

@MateuszManaj
Copy link
Author

right sir. I did this with readthedocs in 100%.

@devyte
Copy link
Collaborator

devyte commented Oct 30, 2019

The HTML you posted isn't valid, there seem to be syntax issues with it. Reported by Chrome and online validation tools.
That being said, it shouldn't crash the ESP.

@devyte
Copy link
Collaborator

devyte commented Oct 31, 2019

Alright, I put the (bad) html in one ESP behind a (async)webserver, and put the sketch in another ESP to test. Building with today's core, it's been running for 30mins with no crash.
This is an excerpt of what I see in the serial monitor.

HTTP] begin...
[HTTP] GET...
[HTTP] GET... code: 200
About to getString!!
Done with getString!!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
... 
</html>

I added the About to getString!! and Done with getString!! prints to fence the getString() call.

In other words, I can't reproduce the crash.

My guess at this point is that you have either a core installation issue which results in a bad binary or you have a bad board.

My suggestion is you pursue this at your end, i.e.:

  1. do a full cleanout of everything Arduino-related, including IDE, arduino15, temp dirs, whatever
  2. do a full reinstall from scratch
  3. rebuild cleanly and retest
  4. if the above still results in a crash, debug at your end, e.g.: go into getString() add printouts etc and figure out why the crash happens.

Closing for now due to can't reproduce. I'll reopen if more info presents itself.

@devyte devyte closed this as completed Oct 31, 2019
@MateuszManaj
Copy link
Author

Hi there,
I tested this code on another board and still prints an exception but different:

20:08:50.970 -> connected with ABC, channel 5
20:08:50.970 -> dhcp client start...
20:08:51.146 -> ip:192.168.8.115,mask:255.255.255.0,gw:192.168.8.1
20:08:51.803 -> [SETUP] WAIT 3...
20:08:52.806 -> [SETUP] WAIT 2...
20:08:53.803 -> [SETUP] WAIT 1...
20:08:54.828 -> FREE HEAP: 51856
20:08:54.828 -> [HTTP] begin...
20:08:54.828 -> [HTTP] GET...
20:08:54.828 -> FREE HEAP: 50136
20:08:54.828 -> [HTTP] GET... code: 200
20:08:54.865 -> Fatal exception �(LoadStoreErrorCause):
20:08:54.865 -> epc1=0x
20:09:02.394 ->  ets Jan  8 2013,rst cause:4, boot mode:(3,6)
20:09:02.394 -> 
20:09:02.394 -> wdt reset
20:09:02.427 -> load 0x4010f000, len 1384, room 16 
20:09:02.427 -> tail 8
20:09:02.427 -> chksum 0x2d
20:09:02.427 -> csum 0x2d
20:09:02.427 -> v9f2cfb82
20:09:02.427 -> ~ld

There is no long tail of errors but still... Can you help me with this a little bit more ?

@devyte
Copy link
Collaborator

devyte commented Nov 2, 2019

Without the ability to reproduce my help is very limited. What I suggest is editing the getString() function by adding Serial.printwhatever, then check in the console which is the last message to print out. That tells you hownthe code execution progresses. If you see that some other function crashes, then you go into that one and do the same. As you go, print out pieces of data (local variables, args, whatever). Eventually you'll reach some code that crashes due to data, e. g. null pointer access or buffer with garbage or missing a null termination, or something that doesn't make sense, like one statement that modifies a completely unrelated piece of data (=> corruption).
It takes time, but you're the only person who can pursue your problem (welcome to open source), at least until you find something that shows a bug in the core code.
Look me up in gitter, I might be able to help a bit better from there.

@ingeniero-david
Copy link

Try this:

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

WiFiClient client;

HTTPClient http;

Serial.print("[HTTP] begin...\n");
if (http.begin(client, "http://192.168.8.218")) {  // HTTP


  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
    Serial.printf("[HTTP] GET... code: %d\n", httpCode);

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

  http.end();
} else {
  Serial.printf("[HTTP} Unable to connect\n");
}

}

delay(10000);
}

@MatejKotas
Copy link

I ran into the same issue. It turned out to be a problem with a missing Content-Length header. When the server doesn't return the header, http.getString() crashes. I fixed it by returning the content length header from the server.

@MateuszManaj
Copy link
Author

MateuszManaj commented Dec 17, 2020 via email

@d-a-v
Copy link
Collaborator

d-a-v commented Dec 17, 2020

Can you try latest master, I think #7691 solved this issue.
(or with the snapshot release)

@ArnoldSchw
Copy link

I experienced the same behaviour: crash on getString(). For me it worked correctly after rewriting
HTTPClient http;
http.begin( url );
to
WiFiClient client;
HTTPClient http;
http.begin( client, url );

The top http.begin( url ) statement was deprecated, but it is still in the examples.
Hope this helps for someone else.

@Flensb
Copy link

Flensb commented Mar 29, 2021

Same here: very repeatable crash on getString(). Under certain very repeatable conditions, I have received "Exception (9) - LoadStoreAlignmentCause: Load or store to an unaligned address". Details are available, if needed by anyone.
Cure was exactly as described by ArnoldSchw. Thank you for posting.

@asinkxcoswt
Copy link

asinkxcoswt commented Apr 10, 2021

I also encounter a similar problem and can be fixed by the solution as described by @Flensb and @ArnoldSchw

In my case, it crashed on a simple GET request to an API which response with a simple short string such as "zone1".

What is weird is that it was working fine at first when I run the API using NodeJs express on my Mac. But It crashed when I deploy the real API in another NodeMCU, even though the request and response are mostly the same.

Thanks.

@reivaxy
Copy link

reivaxy commented Jun 18, 2021

I experienced the same behaviour: crash on getString(). For me it worked correctly after rewriting
HTTPClient http;
http.begin( url );
to
WiFiClient client;
HTTPClient http;
http.begin( client, url );

The top http.begin( url ) statement was deprecated, but it is still in the examples.
Hope this helps for someone else.

It definitely helped me. I stopped working on my project one year ago out of boredom at being unable to solve this crappy issue.

@thebacons
Copy link

thebacons commented Feb 8, 2024

Thank for that reivaxy. I also got a dump on my Wemos D1 R2 Mini when using http.getString();

I rewrote from:
HTTPClient http;
WiFiClient client;
http.begin( client, url );

and change the sequence of WiFiClient, as your code above, and it worked ok,

WiFiClient client;
HTTPClient http;
http.begin( client, url );
String response = http.getString();
Serial.println(response);
http.end();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants