cotestatnt / AsyncTelegram2

Powerful, flexible and secure Arduino Telegram BOT library. Hardware independent, it can be used with any MCU capable of handling an SSL connection.
MIT License
83 stars 25 forks source link

ESP8266 reboots #46

Closed gravedigger21 closed 1 year ago

gravedigger21 commented 2 years ago

I use your library AsyncTelegram2.h Uploaded the lightBot.ino example. Through telegram, I turned on the LED and left it on. After a while I noticed that it went out. I turned it on again, but the situation repeated itself. Then I started the Serial Monitor and saw that after about 30-50 minutes the ESP8266 reboots with an Exception (2) error: 10:36:19.176 -> epc1=0x3ffed570 epc2=0x00000000 epc3=0x00000000 excvaddr=0x3ffed570 depc=0x00000000 or Soft WDT reset. Here is the decoding of EspExceptionDecoder:

`Exception 2: InstructionFetchError: Processor internal physical address or data error during instruction fetch PC: 0x3ffed570 EXCVADDR: 0x3ffed570

Decoding stack results 0x4020a61c: String::equals(char const*) const at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\WString.cpp line 505 0x402226bc: sha2big_out at src/inner.h line 582 0x40222414: sha2big_round at src/hash/sha2big.c line 131 0x40222c9b: br_sha2small_round at src/hash/sha2small.c line 113 0x4023125d: br_ghash_ctmul32 at src/inner.h line 585 0x40224669: br_ssl_engine_set_buffers_bidi at src/ssl/ssl_engine.c line 442 0x40225a59: br_ssl_hs_client_run at src/ssl/ssl_hs_client.c line 151 0x40222b8f: br_sha2small_round at src/hash/sha2small.c line 105 0x40231ca1: br_i15_reduce at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/sys/pgmspace.h line 77 0x40223598: br_i15_montymul at src/int/i15_montmul.c line 39`

Decoding Soft WDT reset: Decoding stack results 0x40208b16: BearSSL::WiFiClientSecure::_clearAuthenticationSettings() at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 98 0x402249aa: br_ssl_engine_recvrec_ack at src/ssl/ssl_engine.c line 743 0x40208d30: BearSSL::WiFiClientSecure::_run_until(unsigned int, bool) at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 436 0x40208f13: BearSSL::WiFiClientSecure::_write(unsigned char const*, unsigned int, bool) at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 287 0x4020a6a8: String::indexOf(String const&, unsigned int) const at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\WString.cpp line 659 0x4020acf6: __wrap_system_restart_local() at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_postmortem.cpp line 212 0x40207b08: ClientContext::_write_from_source(DataSource*) at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src/include/ClientContext.h line 443 0x40100294: __digitalWrite(uint8_t, uint8_t) at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring_digital.cpp line 85 0x40209031: BearSSL::WiFiClientSecure::_wait_for_handshake() at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 562 0x40201a97: AsyncTelegram2::getUpdates() at C:\Users\Admin\Documents\Arduino\libraries\AsyncTelegram2\src\AsyncTelegram2.cpp line 116 0x40201b35: AsyncTelegram2::getUpdates() at C:\Users\Admin\Documents\Arduino\libraries\AsyncTelegram2\src\AsyncTelegram2.cpp line 136 0x40207bc0: WiFiClient::write_P(char const*, unsigned int) at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src/include/DataSource.h line 57 0x40100294: __digitalWrite(uint8_t, uint8_t) at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring_digital.cpp line 85 0x40202b08: ArduinoJson6191_F1::JsonDeserializer , ArduinoJson6191_F1::StringCopier>::parseVariant (ArduinoJson6191_F1::VariantData&, ArduinoJson6191_F1::AllowAllFilter, ArduinoJson6191_F1::NestingLimit) at C:\Users\Admin\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Json/JsonDeserializer.hpp line 66 0x40100228: millis() at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring.cpp line 188 0x40202de3: ArduinoJson6191_F1::JsonDeserializer , ArduinoJson6191_F1::StringCopier>::parseObject (ArduinoJson6191_F1::CollectionData&, ArduinoJson6191_F1::AllowAllFilter, ArduinoJson6191_F1::NestingLimit) at C:\Users\Admin\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Json/JsonDeserializer.hpp line 416 0x40202b08: ArduinoJson6191_F1::JsonDeserializer , ArduinoJson6191_F1::StringCopier>::parseVariant (ArduinoJson6191_F1::VariantData&, ArduinoJson6191_F1::AllowAllFilter, ArduinoJson6191_F1::NestingLimit) at C:\Users\Admin\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Json/JsonDeserializer.hpp line 66 0x40100294: __digitalWrite(uint8_t, uint8_t) at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring_digital.cpp line 85 0x40100a3f: realloc(void*, size_t) at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\umm_malloc\umm_malloc.cpp line 619 0x40204bf2: AsyncTelegram2::getNewMessage(TBMessage&) at C:\Users\Admin\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp line 107 0x40201332: _GLOBAL__sub_I_client() at C:\Users\Admin\Documents\Arduino\libraries\AsyncTelegram2\examples\lightBot/lightBot.ino line 125 0x40201332: _GLOBAL__sub_I_client() at C:\Users\Admin\Documents\Arduino\libraries\AsyncTelegram2\examples\lightBot/lightBot.ino line 125 0x40209480: BearSSL::CertStore::findHashedTA(void*, void*, unsigned int) at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src\CertStoreBearSSL.cpp line 197 0x4020948c: BearSSL::CertStore::findHashedTA(void*, void*, unsigned int) at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src\CertStoreBearSSL.cpp line 200 0x40209480: BearSSL::CertStore::findHashedTA(void*, void*, unsigned int) at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src\CertStoreBearSSL.cpp line 197 0x40209751: HardwareSerial::peek() at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/HardwareSerial.h line 136 0x402099cd: IPAddress::printTo(Print&) const at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\IPAddress.cpp line 154 0x4020b6b9: uart_read(uart_t*, char*, size_t) at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\uart.cpp line 266 0x40100294: __digitalWrite(uint8_t, uint8_t) at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring_digital.cpp line 85 0x40209e2d: Stream::timedRead() at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\Stream.cpp line 38 0x40100196: esp_schedule() at C:\Users\Admin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 125 0x402011ff: loop() at C:\Users\Admin\Documents\Arduino\libraries\AsyncTelegram2\examples\lightBot/lightBot.ino line 109

cotestatnt commented 2 years ago

Hi @gravedigger21 I will try to reproduce the same behaviour, but as first point I would suggest you to update to the latest ESP8266 Core for Arduinobecause you are using a very old major realase 2.7.4 while the latest stable is 3.0.2 with tons of improvements.

gravedigger21 commented 2 years ago

Hi @cotestatnt Many of my old projects don't work with version 3.x.x. So I'm staying on 2.7.4 for now. But I tried to update on another PC to version 3.0.2 and the problem seems to be gone. ESP8266 worked without reboot for more than 2 hours. But when I updated the core, I also updated the ArduinoJson library to the latest version (6.191). and another problem appeared with it - frequent messages "Unable to connect to Telegram server" began to appear in the port monitor. After reverting to older versions - 6.17.3 or 6.18.0, these messages are gone.

cotestatnt commented 2 years ago

Thanks @gravedigger21 for your feedback. You should try to use as IDE VSCode + Platformio because you can set versions for both MCU core and libraries for each project you have (inside the file platformio.ini) so you don't have to lose time with old or new versions every time you need to compile again.

phazz1980 commented 2 years ago

Reboots every 6-8 hours Decoding stack results 0x4021030e: optimistic_yield(uint32_t) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/core_esp8266_features.h line 66 0x4020ab10: BearSSL::WiFiClientSecureCtx::_run_until(unsigned int, bool) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/PolledTimeout.h line 234 0x4022d534: br_ssl_hs_client_init_main at src/ssl/ssl_hs_client.c line 907 0x4022d584: br_ssl_hs_client_run at src/ssl/ssl_hs_client.c line 960 0x4022cb72: br_ssl_engine_hs_reset at src/ssl/ssl_engine.c line 1319 0x4020ac2f: BearSSL::WiFiClientSecureCtx::_wait_for_handshake() at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 585 0x4020ae1f: BearSSL::WiFiClientSecureCtx::_connectSSL(char const*) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 1170 0x4021023c: __esp_yield() at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 116 0x4021093e: __delay(unsigned long) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_wiring.cpp line 54 0x40209d3a: WiFiClient::connect(IPAddress, unsigned short) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src/include/ClientContext.h line 148 0x4020aec1: BearSSL::WiFiClientSecureCtx::connect(char const*, unsigned short) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 231 0x40212246: BearSSL::WiFiClientSecure::connect(char const*, unsigned short) at c:\users\�����\desktop\flprog7.4\idev8\portable\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\bits/shared_ptr_base.h line 1324 0x40202d84: AsyncTelegram2::checkConnection() at c:\Users\�����\Desktop\Flprog7.4\ideV8\portable\sketchbook\libraries\AsyncTelegram2\src\AsyncTelegram2.cpp line 41 0x40202e13: AsyncTelegram2::sendCommand(char const*, char const*, bool) at c:\Users\�����\Desktop\Flprog7.4\ideV8\portable\sketchbook\libraries\AsyncTelegram2\src\AsyncTelegram2.cpp line 64 0x40100325: millis() at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_wiring.cpp line 193 0x4020304c: AsyncTelegram2::getUpdates() at c:\Users\�����\Desktop\Flprog7.4\ideV8\portable\sketchbook\libraries\AsyncTelegram2\src\AsyncTelegram2.cpp line 121 0x40205d9a: AsyncTelegram2::getNewMessage(TBMessage&) at c:\Users\�����\Desktop\Flprog7.4\ideV8\portable\sketchbook\libraries\AsyncTelegram2\src\AsyncTelegram2.cpp line 178 0x40205d6c: AsyncTelegram2::getNewMessage(TBMessage&) at c:\Users\�����\Desktop\Flprog7.4\ideV8\portable\sketchbook\libraries\AsyncTelegram2\src\AsyncTelegram2.cpp line 172 0x40204440: ArduinoJson6183_D1::deserializeJson (ArduinoJson6183_D1::JsonDocument&, String&, ArduinoJson6183_D1::NestingLimit) at c:\Users\�����\Desktop\Flprog7.4\ideV8\portable\sketchbook\libraries\ArduinoJson\src/ArduinoJson/Json/JsonDeserializer.hpp line 32 0x40100325: millis() at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_wiring.cpp line 193 0x40205d9d: AsyncTelegram2::getNewMessage(TBMessage&) at c:\Users\�����\Desktop\Flprog7.4\ideV8\portable\sketchbook\libraries\AsyncTelegram2\src\AsyncTelegram2.cpp line 178 0x40100210: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 181 0x40100210: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 181 0x40100210: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 181 0x40100210: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 181 0x40100210: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 181 0x40217f52: memmove_P at /workdir/repo/newlib/newlib/libc/sys/xtensa/string_pgmspace.c line 189 0x401008db: umm_free_core(umm_heap_context_t*, void*) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 549 0x40100d14: realloc(void*, size_t) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1166 0x40100ae4: malloc(size_t) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 821 0x40100b1c: realloc(void*, size_t) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 853 0x4020eeb0: String::changeBuffer(unsigned int) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/WString.h line 262 0x4021093e: __delay(unsigned long) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_wiring.cpp line 54 0x4020eed1: String::changeBuffer(unsigned int) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\WString.cpp line 202 0x40100325: millis() at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_wiring.cpp line 193 0x40100aba: free(void*) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 595 0x40201850: loop() at C:\Users\Админ\AppData\Local\Temp\flprog\pr77/pr77.ino line 150 0x40100210: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 181 0x40100210: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 181 0x40100210: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 181 0x402101df: __preloop_update_frequency() at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 94 0x40210348: loop_wrapper() at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 196 0x4021033c: loop_wrapper() at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 195 0x40100210: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 181 0x4021035c: loop_wrapper() at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 201 0x401000c8: app_entry() at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 331 0x40232200: poly1305_inner at src/symcipher/poly1305_ctmul32.c line 60 0x40220b22: tcp_split_unsent_seg at core/tcp_out.c line 966

cotestatnt commented 2 years ago

Thanks @phazz1980 It seems that sometimes SSL layer fail to connect to server and then ESP watchdog get triggered. I will try to handle better this kind of situation in order to avoid this. It's not quick process unluckily because in my setup it happens more or less once a day. I will try with a wifi network with poor signal.

phazz1980 commented 2 years ago

this library cannot be used without SSL in any way?

cotestatnt commented 2 years ago

Telegram server accept connection only on port 443 with encrypted data (TLS/SSL).

Any way, certificate validation trust chain can be avoided on ESP side simply enabling the "setInsecure()" option for WiFiClientSecure. The connection is still encrypted, but certicate verification will be bypassed. Even if it is not the best, it could be an acceptable work-around for now because in any case the address to connect to (api.telegram.org) is encoded in the firmware and no one has a way to change it once compiled.

//client.setSession(&session);
  //client.setTrustAnchors(&certificate);
  //client.setBufferSizes(TCP_MSS, TCP_MSS);
  client.setInsecure();
joroMaser commented 2 years ago

@cotestatnt If I remember right the library reconnect each 300 seconds to Telegram server , so 1 time in day that connect is failed because the ESP8266 failed to validate the SSL chain and watchdog is reset? Maybe it is good idea to open an issue on this project ?

@shafr If you use client.setInsecure(); that fix your problem?

What is the disadvantage for using client.setInsecure();

phazz1980 commented 2 years ago

Telegram server accept connection only on port 443 with encrypted data (TLS/SSL).

Any way, certificate validation trust chain can be avoided on ESP side simply enabling the "setInsecure()" option for WiFiClientSecure. The connection is still encrypted, but certicate verification will be bypassed. Even if it is not the best, it could be an acceptable work-around for now because in any case the address to connect to (api.telegram.org) is encoded in the firmware and no one has a way to change it once compiled.

//client.setSession(&session);
//client.setTrustAnchors(&certificate);
//client.setBufferSizes(TCP_MSS, TCP_MSS);
client.setInsecure();

no connection (

cotestatnt commented 2 years ago

This issue is very puzzling for me. It's seem related to library checkConnection() method causing sometime esp8266 soft WDT reset. Moving directly the same instructions used in that method where needed, the reset problem seems disappear but I can't figure why..

Anyway, I will test again for some time and if everything's ok I'll commit the new sources and draft a new release.

cotestatnt commented 2 years ago

No success, I'm still facing with WDT reset

joroMaser commented 2 years ago

@cotestatnt Are you able to recover the reboot consistently? Can you copy here you code?

joroMaser commented 2 years ago

@cotestatnt I running your last commit for few hours and I have got few reboot after print log Start connection handshaking..:

Software reset 08:53 (ctx: sys sp: 3ffff5c0 end: 3fffffb0 offset: 01a0 ), 10:33 ( ctx: sys sp: 3ffff610 end: 3fffffb0 offset: 01a0 ) Hardware reset : 14:29 Software reset 16:15 (ctx: cont sp: 3ffff5f0 end: 4010298b offset: 01a0 ) , 18:10 ( ctx: sys sp: 3ffff5f0 end: 3fffffb0 offset: 01a0 )

Do you have any idea how to print some log that will help you to understand that ?

cotestatnt commented 2 years ago

Hello to everyone. I have an ESP-01 running without reboots since a couple of days. Could someone give me some feedback about latest release?

Thanks in advance.

joroMaser commented 2 years ago

@cotestatnt I run your last commit and saw this log


[D][AsyncTelegram2.cpp:63] reset(): Restart Telegram connection

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 111 seconds ago

[D][AsyncTelegram2.cpp:63] reset(): Restart Telegram connection

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 23 seconds ago

[D][AsyncTelegram2.cpp:63] reset(): Restart Telegram connection

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...

Unable to connect to Telegram server

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...

Unable to connect to Telegram server

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...

Unable to connect to Telegram server

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...

Unable to connect to Telegram server

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...

Unable to connect to Telegram server

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 148 seconds ago

[D][AsyncTelegram2.cpp:63] reset(): Restart Telegram connection

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 27 seconds ago

[D][AsyncTelegram2.cpp:63] reset(): Restart Telegram connection

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 21 seconds ago

[D][AsyncTelegram2.cpp:63] reset(): Restart Telegram connection

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 29 seconds ago

[D][AsyncTelegram2.cpp:63] reset(): Restart Telegram connection

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 31 seconds ago

[D][AsyncTelegram2.cpp:63] reset(): Restart Telegram connection

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 27 seconds ago

[D][AsyncTelegram2.cpp:63] reset(): Restart Telegram connection

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...

Unable to connect to Telegram server

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 52 seconds ago

[D][AsyncTelegram2.cpp:63] reset(): Restart Telegram connection

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 26 seconds ago

[D][AsyncTelegram2.cpp:63] reset(): Restart Telegram connection

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 22 seconds ago

[D][AsyncTelegram2.cpp:63] reset(): Restart Telegram connection

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 53 seconds ago

[D][AsyncTelegram2.cpp:63] reset(): Restart Telegram connection

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 34 seconds ago

[D][AsyncTelegram2.cpp:63] reset(): Restart Telegram connection

[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...

Unable to connect to Telegram server

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (0):
epc1=0x4e9a335d epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

>>>stack>>>

ctx: bearssl
sp: 3fff1528 end: 3fff17b8 offset: 0190

...........
ctx: cont
sp: 3ffff920 end: 3fffffc0 offset: 0000
........
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Now I will start new running

joroMaser commented 2 years ago

I have got an exception again


[D][AsyncTelegram2.cpp:163] getUpdates():   Connection closed from server
[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 294 seconds ago

[D][AsyncTelegram2.cpp:163] getUpdates():   Connection closed from server
[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 302 seconds ago

[D][AsyncTelegram2.cpp:163] getUpdates():   Connection closed from server
[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 301 seconds ago

[D][AsyncTelegram2.cpp:163] getUpdates():   Connection closed from server
[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 299 seconds ago

[D][AsyncTelegram2.cpp:163] getUpdates():   Connection closed from server
[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 300 seconds ago

[D][AsyncTelegram2.cpp:163] getUpdates():   Connection closed from server
[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 312 seconds ago

[D][AsyncTelegram2.cpp:163] getUpdates():   Connection closed from server
[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 300 seconds ago

[D][AsyncTelegram2.cpp:163] getUpdates():   Connection closed from server
[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 302 seconds ago

[D][AsyncTelegram2.cpp:163] getUpdates():   Connection closed from server
[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 300 seconds ago

[D][AsyncTelegram2.cpp:163] getUpdates():   Connection closed from server
[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...
[D][AsyncTelegram2.cpp:43] checkConnection():   Connected using Telegram hostname
Last connection was 300 seconds ago

[D][AsyncTelegram2.cpp:234] getNewMessage():    
{
  "ok": true,
  "result": [
    {
      "update_id": XXXXXXXXX,
      "message": {
        "message_id": XXX,
        "from": {
          "id": XXXXXXXXX,
          "is_bot": false,
          "first_name": "XXXXXXXXX",
          "language_code": "en"
        },
        "chat": {
          "id": -XXXXXXXXX,
          "title": "XXXXXXXXX",
          "type": "supergroup"
        },
        "date": XXXXXXXXX,
        "text": "Ggg"
      }
    }
  ]
}

[D][AsyncTelegram2.cpp:419] sendMessage():  
{
  "chat_id": -XXXXXXXXX,
  "text": "Hi",
  "parse_mode": "HTML",
  "reply_markup": {
    "inline_keyboard": [
      [
        {
          "text": " press here!",
          "callback_data": "press1"
        }
      ]
    ]
  }
}

[D][AsyncTelegram2.cpp:163] getUpdates():   Connection closed from server
[D][AsyncTelegram2.cpp:29] checkConnection():   Start handshaking...

Unable to connect to Telegram server

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (0):
epc1=0x3e77b67c epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

>>>stack>>>

ctx: bearssl
sp: 3fff12e8 end: 3fff17b8 offset: 0190
joroMaser commented 2 years ago

@cotestatnt I will be happy to get your comment about the 2 exceptions from bearssl.

Anyway I run your last commit about 5 days without reboot. What did you change that prevent watchdog reboot?

phazz1980 commented 2 years ago
Decoding stack results
0x40212a4c: BearSSL::WiFiClientSecureCtx::_run_until(unsigned int, bool) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 474
0x4023a0a0: br_ssl_hs_client_init_main at src/ssl/ssl_hs_client.c line 907
0x40212a4c: BearSSL::WiFiClientSecureCtx::_run_until(unsigned int, bool) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 474
0x4023a0a0: br_ssl_hs_client_init_main at src/ssl/ssl_hs_client.c line 907
0x4023a0f0: br_ssl_hs_client_run at src/ssl/ssl_hs_client.c line 960
0x402396de: br_ssl_engine_hs_reset at src/ssl/ssl_engine.c line 1319
0x4023a0f0: br_ssl_hs_client_run at src/ssl/ssl_hs_client.c line 960
0x402396de: br_ssl_engine_hs_reset at src/ssl/ssl_engine.c line 1319
0x40212b57: BearSSL::WiFiClientSecureCtx::_wait_for_handshake() at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 585
0x40212d47: BearSSL::WiFiClientSecureCtx::_connectSSL(char const*) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp549
0x40100cd4: realloc(void*, size_t) at C:\Users\�����\Desktop\Flprog7.4\ideV8\portable\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1166

reboot occurs at the moment of connecting to Wi-Fi or immediately connecting the router to the Internet

konig87nikkinakki commented 2 years ago

i had the same problem with ESP8266, and i also tried other libraries: sooner or later it happened again. So i moved to ESP32 (days to wait after buy to deliver, bad sleeping, i hate to wait for days) but with ESP32 library works reeeeally fine, i didnt have problems yet.