Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit b5ad450

Browse files
authored
v1.4.0 to fix crashing bug
### Releases v1.4.0 1. Fix crashing bug when request a non-existing IP. Check [Http GET polling causes crash when host disconnected #22](#22) 2. Modify `platform.ini` to avoid compile error with PIO when using ESP8266/ESP32
1 parent d21dafe commit b5ad450

21 files changed

+147
-48
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1515
Please ensure to specify the following:
1616

1717
* Arduino IDE version (e.g. 1.8.16) or Platform.io version
18-
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v3.0.2, ESP32 v2.0.0 or STM32 v2.1.0)
18+
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v3.0.2, ESP32 v2.0.1 or STM32 v2.1.0)
1919
* Contextual information (e.g. what you were trying to achieve)
2020
* Simplest possible steps to reproduce
2121
* Anything that might be relevant in your opinion, such as:
@@ -27,9 +27,9 @@ Please ensure to specify the following:
2727

2828
```
2929
Arduino IDE version: 1.8.16
30-
ESP32 Core Version 2.0.0
30+
ESP32 Core Version 2.0.1
3131
OS: Ubuntu 20.04 LTS
32-
Linux xy-Inspiron-3593 5.4.0-86-generic #97-Ubuntu SMP Fri Sep 17 19:19:40 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
32+
Linux xy-Inspiron-3593 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
3333
3434
Context:
3535
I encountered an endless loop while trying to connect to Local WiFi.

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ IPAddress ip(192, 168, 2, 232);
649649

650650
```
651651
Start AsyncHTTPRequest_STM32 on NUCLEO_F767ZI
652-
AsyncHTTPRequest_Generic v1.3.1
652+
AsyncHTTPRequest_Generic v1.4.0
653653
AsyncHTTPRequest @ IP : 192.168.2.72
654654
655655
**************************************
@@ -694,7 +694,7 @@ week_number: 37
694694

695695
```
696696
Starting AsyncHTTPRequest_ESP_WiFiManager using LittleFS on ESP8266_NODEMCU
697-
AsyncHTTPRequest_Generic v1.3.1
697+
AsyncHTTPRequest_Generic v1.4.0
698698
Stored: SSID = HueNet1, Pass = 12345678
699699
Got stored Credentials. Timeout 120s
700700
ConnectMultiWiFi in setup
@@ -727,7 +727,7 @@ HHHHHH
727727

728728
```
729729
Starting AsyncHTTPRequest_ESP_WiFiManager using SPIFFS on ESP32_DEV
730-
AsyncHTTPRequest_Generic v1.3.1
730+
AsyncHTTPRequest_Generic v1.4.0
731731
Stored: SSID = HueNet1, Pass = 12345678
732732
Got stored Credentials. Timeout 120s
733733
ConnectMultiWiFi in setup
@@ -778,7 +778,7 @@ HHHHHHHHH HHHHHHHHHH HHHHHHHHHH
778778

779779
```
780780
Starting AsyncHTTPRequest_ESP using ESP8266_NODEMCU
781-
AsyncHTTPRequest_Generic v1.3.1
781+
AsyncHTTPRequest_Generic v1.4.0
782782
Connecting to WiFi SSID: HueNet1
783783
...........
784784
HTTP WebServer is @ IP : 192.168.2.81
@@ -810,7 +810,7 @@ HHHHHHHHH HHHHHHHHHH HHHHHHHHHH H
810810

811811
```
812812
Start AsyncWebClientRepeating_STM32 on NUCLEO_F767ZI
813-
AsyncHTTPRequest_Generic v1.3.1
813+
AsyncHTTPRequest_Generic v1.4.0
814814
AsyncHTTPRequest @ IP : 192.168.2.72
815815
816816
**************************************
@@ -865,7 +865,7 @@ AsyncHTTPRequest @ IP : 192.168.2.72
865865

866866
```
867867
Start AsyncWebClientRepeating_STM32_LAN8720 on BLACK_F407VE
868-
AsyncHTTPRequest_Generic v1.3.1
868+
AsyncHTTPRequest_Generic v1.4.0
869869
AsyncHTTPRequest @ IP : 192.168.2.150
870870
871871
@@ -920,8 +920,8 @@ AsyncHTTPRequest @ IP : 192.168.2.150
920920

921921
```
922922
Starting AsyncHTTPRequest_WT32_ETH01 on ESP32_DEV with ETH_PHY_LAN8720
923-
WebServer_WT32_ETH01 v1.2.1
924-
AsyncHTTPRequest_Generic v1.3.1
923+
WebServer_WT32_ETH01 v1.3.0
924+
AsyncHTTPRequest_Generic v1.4.0
925925
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.232, FULL_DUPLEX, 100Mbps
926926
AsyncHTTPRequest @ IP : 192.168.2.232
927927
@@ -946,8 +946,8 @@ H
946946

947947
```
948948
Starting AsyncHTTPRequest_WT32_ETH01 on ESP32_DEV with ETH_PHY_LAN8720
949-
WebServer_WT32_ETH01 v1.2.1
950-
AsyncHTTPRequest_Generic v1.3.1
949+
WebServer_WT32_ETH01 v1.3.0
950+
AsyncHTTPRequest_Generic v1.4.0
951951
ETH MAC: A8:03:2A:A1:61:73, IPv4: 192.168.2.232, FULL_DUPLEX, 100Mbps
952952
AsyncHTTPRequest @ IP : 192.168.2.232
953953
@@ -1037,6 +1037,8 @@ This library is based on, modified, bug-fixed and improved from:
10371037

10381038
5. Thanks to [spdi](https://github.com/spdi) to report [**'Connection' header expects 'disconnect' instead 'close' ? #13**](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/13) leading to new release v1.1.3 to fix bug.
10391039

1040+
6. Thanks to [andrewk123](https://github.com/andrewk123) to report [**Http GET polling causes crash when host disconnected #22**](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/22) leading to new release v1.4.0 to fix bug.
1041+
10401042

10411043
<table>
10421044
<tr>
@@ -1045,6 +1047,7 @@ This library is based on, modified, bug-fixed and improved from:
10451047
<td align="center"><a href="https://github.com/gleniat"><img src="https://github.com/gleniat.png" width="100px;" alt="gleniat"/><br /><sub><b>gleniat</b></sub></a><br /></td>
10461048
<td align="center"><a href="https://github.com/baddwarf"><img src="https://github.com/baddwarf.png" width="100px;" alt="baddwarf"/><br /><sub><b>BadDwarf</b></sub></a><br /></td>
10471049
<td align="center"><a href="https://github.com/spdi"><img src="https://github.com/spdi.png" width="100px;" alt="spdi"/><br /><sub><b>spdi</b></sub></a><br /></td>
1050+
<td align="center"><a href="https://github.com/andrewk123"><img src="https://github.com/andrewk123.png" width="100px;" alt="andrewk123"/><br /><sub><b>andrewk123</b></sub></a><br /></td>
10481051
</tr>
10491052
</table>
10501053

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
## Table of Contents
1313

1414
* [Changelog](#changelog)
15+
* [Releases v1.4.0](#releases-v140)
1516
* [Releases v1.3.1](#releases-v131)
1617
* [Releases v1.3.0](#releases-v130)
1718
* [Releases v1.2.0](#releases-v120)
@@ -30,6 +31,11 @@
3031

3132
## Changelog
3233

34+
### Releases v1.4.0
35+
36+
1. Fix crashing bug when request a non-existing IP. Check [Http GET polling causes crash when host disconnected #22](https://github.com/khoih-prog/AsyncHTTPRequest_Generic/issues/22)
37+
2. Modify `platform.ini` to avoid compile error with PIO when using ESP8266/ESP32
38+
3339
### Releases v1.3.1
3440

3541
1. Update `platform.ini` and `library.json` to use original `khoih-prog` instead of `khoih.prog` after PIO fix

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"AsyncHTTPRequest_Generic",
3-
"version": "1.3.1",
3+
"version": "1.4.0",
44
"description":"Simple Async HTTP Request library, supporting GET, POST, PUT, PATCH, DELETE and HEAD, on top of AsyncTCP libraries, such as AsyncTCP, ESPAsyncTCP, AsyncTCP_STM32, etc.. for ESP32 (including ESP32-S2), WT32_ETH01 (ESP32 + LAN8720), ESP8266 and currently STM32 with LAN8720 or built-in LAN8742A Ethernet.",
55
"keywords":"communication, async, tcp, http, ESP8266, ESP32, ESP32-S2, wt32-eth01, ESPAsyncTCP, AsyncTCP, stm32, ethernet, wifi, lan8742a, lan8720, f407ve, nucleo, nucleo-144, stm32f7, stm32f4",
66
"authors": [

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=AsyncHTTPRequest_Generic
2-
version=1.3.1
2+
version=1.4.0
33
author=Bob Lemaire,Khoi Hoang <[email protected]>
44
maintainer=Khoi Hoang <[email protected]>
55
license=MIT

platformio/platformio.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ lib_deps =
5050
me-no-dev/AsyncTCP@>=1.1.1
5151
me-no-dev/ESPAsyncTCP@>=1.2.2
5252
; philbowles/STM32AsyncTCP
53-
https://github.com/khoih-prog/STM32AsyncTCP.git
54-
stm32duino/STM32duino LwIP@>=2.1.2
55-
stm32duino/STM32duino STM32Ethernet@>=1.2.0
53+
; https://github.com/khoih-prog/STM32AsyncTCP.git
54+
; stm32duino/STM32duino LwIP@>=2.1.2
55+
; stm32duino/STM32duino STM32Ethernet@>=1.2.0
5656
khoih-prog/ESPAsync_WiFiManager@>=1.9.3
5757
lorol/LittleFS_esp32@>=1.0.6
58-
khoih-prog/WebServer_WT32_ETH01@>=1.2.1
58+
; khoih-prog/WebServer_WT32_ETH01@>=1.2.1
5959

6060
build_flags =
6161
; set your debug output (default=Serial)

src/AsyncHTTPRequest_Debug_Generic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1818
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
1919
20-
Version: 1.3.1
20+
Version: 1.4.0
2121
2222
Version Modified By Date Comments
2323
------- ----------- ---------- -----------
@@ -33,6 +33,7 @@
3333
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
3434
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
3535
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
36+
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
3637
*****************************************************************************************************************************/
3738

3839
#pragma once

src/AsyncHTTPRequest_Generic.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1818
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
1919
20-
Version: 1.3.1
20+
Version: 1.4.0
2121
2222
Version Modified By Date Comments
2323
------- ----------- ---------- -----------
@@ -33,14 +33,15 @@
3333
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
3434
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
3535
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
36+
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
3637
*****************************************************************************************************************************/
3738

3839
#pragma once
3940

4041
#ifndef ASYNC_HTTP_REQUEST_GENERIC_H
4142
#define ASYNC_HTTP_REQUEST_GENERIC_H
4243

43-
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.3.1"
44+
#define ASYNC_HTTP_REQUEST_GENERIC_VERSION "AsyncHTTPRequest_Generic v1.4.0"
4445

4546
#include <Arduino.h>
4647

src/AsyncHTTPRequest_Impl_Generic.h

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1818
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
1919
20-
Version: 1.3.1
20+
Version: 1.4.0
2121
2222
Version Modified By Date Comments
2323
------- ----------- ---------- -----------
@@ -33,6 +33,7 @@
3333
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
3434
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
3535
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
36+
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
3637
*****************************************************************************************************************************/
3738

3839
#pragma once
@@ -259,9 +260,13 @@ bool AsyncHTTPRequest::send(String body)
259260
return false;
260261
}
261262
//////
263+
264+
AHTTP_LOGERROR1("01) send String body =", body);
262265

263266
MUTEX_LOCK(false)
264267

268+
AHTTP_LOGERROR1("02) send String body =", body);
269+
265270
_addHeader("Content-Length", String(body.length()).c_str());
266271

267272
if ( ! _buildRequest())
@@ -271,9 +276,15 @@ bool AsyncHTTPRequest::send(String body)
271276
return false;
272277
}
273278

279+
AHTTP_LOGERROR1("1) send String body =", body);
280+
274281
_request->write(body);
282+
283+
AHTTP_LOGERROR1("2) send String body =", body);
275284
_send();
276285

286+
AHTTP_LOGERROR1("3) send String body =", body);
287+
277288
_AHTTP_unlock;
278289

279290
return true;
@@ -790,12 +801,27 @@ size_t AsyncHTTPRequest::_send()
790801

791802
AHTTP_LOGDEBUG1("_send(), _request->available =", _request->available());
792803

804+
#if 1
805+
if ( ! _client->connected())
806+
{
807+
AHTTP_LOGDEBUG("!connected");
808+
809+
return 0;
810+
}
811+
else if ( ! _client->canSend())
812+
{
813+
AHTTP_LOGDEBUG("*can't send");
814+
815+
return 0;
816+
}
817+
#else
793818
if ( ! _client->connected() || ! _client->canSend())
794819
{
795820
AHTTP_LOGDEBUG("*can't send");
796821

797822
return 0;
798823
}
824+
#endif
799825

800826
size_t supply = _request->available();
801827
size_t demand = _client->space();
@@ -1009,17 +1035,17 @@ void AsyncHTTPRequest::_onDisconnect(AsyncClient* client)
10091035

10101036
if (_readyState < readyStateOpened)
10111037
{
1038+
AHTTP_LOGDEBUG("HTTPCODE_NOT_CONNECTED");
10121039
_HTTPcode = HTTPCODE_NOT_CONNECTED;
10131040
}
10141041
else if (_HTTPcode > 0 &&
10151042
(_readyState < readyStateHdrsRecvd || (_contentRead + _response->available()) < _contentLength))
10161043
{
1044+
AHTTP_LOGDEBUG("HTTPCODE_CONNECTION_LOST");
10171045
_HTTPcode = HTTPCODE_CONNECTION_LOST;
10181046
}
10191047

1020-
SAFE_DELETE(_client)
1021-
1022-
_client = nullptr;
1048+
AHTTP_LOGDEBUG1("_HTTPcode = ", _HTTPcode);
10231049

10241050
SAFE_DELETE_ARRAY(_connectedHost)
10251051

src/utility/xbuf.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1818
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
1919
20-
Version: 1.3.1
20+
Version: 1.4.0
2121
2222
Version Modified By Date Comments
2323
------- ----------- ---------- -----------
@@ -33,6 +33,7 @@
3333
1.2.0 K Hoang 11/04/2021 Add support to LAN8720 using STM32F4 or STM32F7
3434
1.3.0 K Hoang 09/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards
3535
1.3.1 K Hoang 09/10/2021 Update `platform.ini` and `library.json`
36+
1.4.0 K Hoang 23/11/2021 Fix crashing bug when request a non-existing IP
3637
*****************************************************************************************************************************/
3738

3839
/********************************************************************************************

0 commit comments

Comments
 (0)