Github Upload Boards Devices Community Docs Blog

ESP8266 Runtime exceptions(would cause restart) with OMG when MQTT broker stopped

Hi there,

As I mentioned in this thread

ESP32 BLE gateway dying every X days - #107 by lkisme

I am facing OMG dying issue and want to resolve it, so I used the “screen” command to connect one of my ESP8266 device with OMG firmware, and found out that sometimes the OMG would throw a exception, which may be one of the root causes.

The decoded messages are the same:

Exception Cause: 28  [LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads]

0x4020b447: BearSSL::WiFiClientSecure::getLastSSLError(char*, unsigned int) at ??:?
0x402075b6: PubSubClient::setBufferSize(unsigned short) at ??:?
0x40201f8a: connectMQTT() at ??:?
0x40100d53: umm_free_core at umm_malloc.cpp:?
0x40100fdb: free at ??:?
0x4022adb0: base64_encode_value at ??:?
0x402347cd: operator delete(void*) at /workdir/repo/gcc/libstdc++-v3/libsupc++/del_op.cc:48
0x40223e84: _ZN7esp826613polledTimeout15timeoutTemplateILb0ENS0_11YieldPolicy9DoNothingENS0_10TimePolicy8TimeUnitINS4_16TimeSourceMillisELy1000EEEE5resetEv$isra$15 at LEAmDNS_Control.cpp:?
0x4022493b: esp8266::MDNSImplementation::MDNSResponder::_updateProbeStatus() at ??:?
0x4022adb0: base64_encode_value at ??:?
0x4022545d: esp8266::MDNSImplementation::MDNSResponder::_process(bool) at ??:?
0x4026cfc7: wifi_station_get_connect_status at ??:?
0x40223996: esp8266::MDNSImplementation::MDNSResponder::update() at ??:?
0x40204fb8: loop at ??:?
0x40219234: loop_wrapper() at core_esp8266_main.cpp:?
0x401013b9: cont_wrapper at ??:?

I managed to reproduce this issue on 2 of the devices, here are the procedures to reproduce:

Simulate “MQTT_CONNECTION_TIMEOUT”

  1. I used a ESP-wroom-02(ESP8266 + 2M flash) chip and the code change is here :GitHub - lkisme/OpenMQTTGateway at ibox
  2. Start a mqtt server on a computer in LAN, add a breakpoint on the line of process the “Connect” request to simulate a “mqtt connect timeout”
  3. Let OMG use the broker we setup at step #2

here is the original exception output:

W: failed, ssl error code=2555905
W: MQTT connection...
W: failure_number_mqtt: 3
W: failed, rc=-2
W: failed, ssl error code=2555905
W: MQTT connection...
W: failure_number_mqtt: 4
W: failed, rc=-4

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

[10:51:43.005] Exception (28):
[10:51:43.005] epc1=0x4020b447 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
[10:51:43.009] 
[10:51:43.009] >>>stack>>>

Simulate “MQTT_CONNECT_BAD_PROTOCOL”(MQTT_CONNECTION_TIMEOUT wouldn’t cause exception on this board)

  1. I used a NodeMCU v3(Lolin) dev board and the code change is here : GitHub - lkisme/OpenMQTTGateway at 8266-098
  2. Start a mqtt server on a computer in LAN, and the broker doesn’t support mqttV4 protocol.
  3. Let OMG use the broker we setup at step #2, then wait a moment, the exception will be thrown at the third time it failed to connect to the broker.

here is the original exception output:

00:02:31.748 -> N: ************** Setup OpenMQTTGateway end **************
00:02:31.748 -> W: MQTT connection...
00:02:31.819 -> W: failure_number_mqtt: 1
00:02:31.819 -> W: failed, rc=1
00:02:31.853 -> W: failed, ssl error code=-1000
00:02:38.827 -> W: MQTT connection...
00:02:39.069 -> W: failure_number_mqtt: 2
00:02:39.069 -> W: failed, rc=1
00:02:39.069 -> W: failed, ssl error code=-1000
00:02:46.072 -> W: MQTT connection...
00:02:46.145 -> W: failure_number_mqtt: 3
00:02:46.145 -> W: failed, rc=1
00:02:46.145 -> 
00:02:46.145 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
00:02:46.145 -> 
00:02:46.145 -> Exception (28):
00:02:46.145 -> epc1=0x4020b09b epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
00:02:46.145 -> 
00:02:46.145 -> >>>stack>>>

here is my NodeMCU board on which I reproduce the exception:

Hi,

Thanks for taking the time to isolate and give details, this seems to be related to an out of memory error?

I’m suspecting a memory issue with ZgatewayRF or RCSwitch.
I push your code to a NodeMCU and will let it run several hours.

In my case, it seems related to the bad condition of WiFi connection to connect to the mqtt broker, so I assumed it may be some problems with pubsubclient? Anyway I’m not expert on C/C++.

FYI, I used this project (GitHub - shimonxin/light-mqtt-server: A lightweight MQTT server)to simulate the mqtt connection problem, although you may need a Java/maven dev environment to run it. with controlled mqtt broker, you don’t need to wait hours.

Do you reproduce the issue with the unmodified OMG code ?
Just by using a PIO environment like this one:

[env:nodemcuv2-rf]
platform = ${com.esp8266_platform}
board = nodemcuv2
lib_deps =
  ${com-esp.lib_deps}
   ${libraries.rc-switch}
  ${libraries.esp8266_mdns}
  ; ${libraries.unifiedsensor}
  ; ${libraries.dht}
build_flags =
  ${com-esp.build_flags}
   '-DZgatewayRF="RF"'
  '-DZactuatorPWM="PWM"'
  '-DZactuatorONOFF="ONOFF"'
  '-DRF_EMITTER_GPIO=5'
  '-DRF_RECEIVER_GPIO=4'
  '-DMQTT_SERVER="ha.cn"'
  '-DGateway_Name="OpenMQTTGateway_ESP_02"'
board_build.flash_mode = dout
upload_protocol = espota
upload_port = 192.168.3.239
upload_flags =
  --auth=OTAPASSWORD
  --port=8266

And having the original v0.9.8.
Note that I have combined your configuration into one platformio environment.

Yes, the issue is reproducible, and the decoded message is the same.

Here is what I did:

  1. Checkout a new branch from the tag 0.9.8.
  2. Change the platform.ini like you wrote, then compile
  3. Flash the nodemcu(Lolin) with the firmware built at #2 by using NodeMCU PyFlasher(Mac OS version).
  4. Config wifi info & mqtt broker address(192.168.3.82) in wifimanager page.
  5. Start the Mqtt server at my Mac(192.168.3.82), and simulate “connection timeout” and “connect failed”

Decoded message:

Exception Cause: 28  [LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads]

0x4020b5cf: BearSSL::WiFiClientSecure::getLastSSLError(char*, unsigned int) at ??:?
0x4020773e: PubSubClient::setBufferSize(unsigned short) at ??:?
0x40201f46: connectMQTT() at ??:?
0x40217070: Print::print(char) at ??:?
0x40216a24: HardwareSerial::write(unsigned char const*, unsigned int) at ??:?
0x40207b7c: Logging::print(__FlashStringHelper const*, __va_list_tag) at ??:?
0x40216e0d: Print::write(char const*) at ??:?
0x4027fb70: chip_v6_unset_chanfreq at ??:?
0x4027fb70: chip_v6_unset_chanfreq at ??:?
0x40201a8c: void Logging::printLevel<__FlashStringHelper const*>(int, __FlashStringHelper const*, ...) at ??:?
0x40224010: _ZN7esp826613polledTimeout15timeoutTemplateILb0ENS0_11YieldPolicy9DoNothingENS0_10TimePolicy8TimeUnitINS4_16TimeSourceMillisELy1000EEEE5resetEv$isra$15 at LEAmDNS_Control.cpp:?
0x40224a86: esp8266::MDNSImplementation::MDNSResponder::_updateProbeStatus() at ??:?
0x4022af40: base64_encode_value at ??:?
0x402255e9: esp8266::MDNSImplementation::MDNSResponder::_process(bool) at ??:?
0x4026d157: wifi_station_get_connect_status at ??:?
0x40223b22: esp8266::MDNSImplementation::MDNSResponder::update() at ??:?
0x40205140: loop at ??:?
0x402193c0: loop_wrapper() at core_esp8266_main.cpp:?
0x401013b9: cont_wrapper at ??:?

Here is part of the original serial output(only exceptions) with timestamp:

21:53:57.976 -> N: ************** Setup OpenMQTTGateway end **************
21:53:57.976 -> W: MQTT connection...
21:53:59.348 -> W: failure_number_mqtt: 1
21:53:59.348 -> W: failed, rc=-2
21:53:59.348 ->
21:53:59.348 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
21:53:59.348 -> 
21:53:59.348 -> Exception (9):
21:53:59.348 -> epc1=0x4020b5cf epc2=0x00000000 epc3=0x00000000 excvaddr=0x00460046 depc=0x00000000
21:53:59.348 -> 
21:53:59.348 -> >>>stack>>>
21:53:59.348 -> 
21:53:59.348 -> ctx: cont
21:53:59.348 -> sp: 3ffffcd0 end: 3fffffc0 offset: 0190
21:53:59.388 -> 3ffffe60:  00000001 00000000 00000001 4020773e  
21:53:59.388 -> 3ffffe70:  00000001 3ffeffa8 3fff0330 40201f46  
21:53:59.388 -> 3ffffe80:  00000001 3ffe88bf 3fff1894 40217070  
21:53:59.388 -> 3ffffe90:  40216a24 3fff05f0 3ffe9476 40207b7c  
21:53:59.388 -> 3ffffea0:  3ffffef0 3ffffee0 0000000c 40216e0d  
21:53:59.388 -> 3ffffeb0:  4027fb70 3ffe9404 3fff0330 0000075b  
21:53:59.388 -> 3ffffec0:  4027fb70 3ffe9404 3fff0330 40201a8c  
21:53:59.388 -> 3ffffed0:  00000000 4bc6a7f0 00014120 00000001  
21:53:59.423 -> 3ffffee0:  00000000 00000000 4bc6a7f0 00000000  
21:53:59.423 -> 3ffffef0:  00000001 656d6f68 65704f2f 54514d6e  
21:53:59.423 -> 3fffff00:  74614754 79617765 5053455f 5345545f  
21:53:59.423 -> 3fffff10:  574c2f54 3fff0054 3fff13e4 40224010  
21:53:59.423 -> 3fffff20:  4652225b 50222c22 3fff13ac 40224a86  
21:53:59.423 -> 3fffff30:  4022af40 00000000 feefeffe feefeffe  
21:53:59.423 -> 3fffff40:  00000000 4bc6a7f0 00014120 00000000  
21:53:59.423 -> 3fffff50:  3fffdad0 3fff002c 3fff0e0c 402255e9  
21:53:59.423 -> 3fffff60:  4026d157 feefeffe 3fff04c0 40223b22  
21:53:59.459 -> 3fffff70:  3fff0034 3ffeffa8 3ffeffa8 00000000  
21:53:59.459 -> 3fffff80:  3fff0034 3ffeffa8 00014120 40205140  
21:53:59.459 -> 3fffff90:  feefeffe feefeffe feefeffe 3fff0730  
21:53:59.459 -> 3fffffa0:  3fffdad0 00000000 3fff06f0 402193c0  
21:53:59.459 -> 3fffffb0:  feefeffe feefeffe 3ffe86b8 401013b9  
21:53:59.459 -> <<<stack<<<
21:53:59.459 -> 
21:53:59.459 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
21:53:59.492 -> 
21:53:59.492 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)

....
21:54:01.364 -> N: ************** Setup OpenMQTTGateway end **************
21:54:01.364 -> W: MQTT connection...
21:54:01.399 -> W: failure_number_mqtt: 1
21:54:01.399 -> W: failed, rc=-2
21:54:01.399 -> 
21:54:01.399 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
21:54:01.399 -> 
21:54:01.399 -> Exception (28):
21:54:01.399 -> epc1=0x4020b5cf epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
21:54:01.399 -> 
21:54:01.399 -> >>>stack>>>
21:54:01.399 -> 
21:54:01.399 -> ctx: cont
21:54:01.399 -> sp: 3ffffcd0 end: 3fffffc0 offset: 0190
21:54:01.437 -> 3ffffe60:  00000001 000001c0 00000001 4020773e  
21:54:01.437 -> 3ffffe70:  00000001 3ffeffa8 3fff0330 40201f46  
21:54:01.437 -> 3ffffe80:  00000001 3ffe88bf 3fff1db4 40217070  
21:54:01.437 -> 3ffffe90:  40216a24 3fff05f0 3ffe9476 40207b7c  
21:54:01.437 -> 3ffffea0:  3ffffef0 3ffffee0 0000000c 40216e0d  
21:54:01.437 -> 3ffffeb0:  4027fb70 3ffe9404 3fff0330 0000075b  
21:54:01.437 -> 3ffffec0:  4027fb70 3ffe9404 3fff0330 40201a8c  
21:54:01.437 -> 3ffffed0:  00000000 4bc6a7f0 00000744 00000001  
21:54:01.472 -> 3ffffee0:  00000000 00000000 4bc6a7f0 00000000  
21:54:01.472 -> 3ffffef0:  00000001 656d6f68 65704f2f 54514d6e  
21:54:01.472 -> 3fffff00:  74614754 79617765 5053455f 5345545f  
21:54:01.472 -> 3fffff10:  574c2f54 3fff0054 3fff2de4 40224010  
21:54:01.472 -> 3fffff20:  4652225b 50222c22 3fff2dac 40224a86  
21:54:01.472 -> 3fffff30:  4022af40 00000000 feefeffe feefeffe  
21:54:01.472 -> 3fffff40:  00000000 4bc6a7f0 00000743 00000000  
21:54:01.509 -> 3fffff50:  3fffdad0 3fff002c 3fff0e0c 402255e9  
21:54:01.509 -> 3fffff60:  4026d157 feefeffe 3fff04c0 40223b22  
21:54:01.509 -> 3fffff70:  3fff0034 3ffeffa8 3ffeffa8 00000000  
21:54:01.509 -> 3fffff80:  3fff0034 3ffeffa8 00000743 40205140  
21:54:01.509 -> 3fffff90:  feefeffe feefeffe feefeffe 3fff0730  
21:54:01.509 -> 3fffffa0:  3fffdad0 00000000 3fff06f0 402193c0  
21:54:01.509 -> 3fffffb0:  feefeffe feefeffe 3ffe86b8 401013b9  
21:54:01.509 -> <<<stack<<<
21:54:01.509 -> 
21:54:01.509 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
21:54:01.547 -> 
21:54:01.547 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)

....
21:54:04.472 -> W: MQTT connection...
21:54:04.472 -> W: failure_number_mqtt: 1
21:54:04.472 -> W: failed, rc=-2
21:54:04.472 -> 
21:54:04.472 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
21:54:04.472 -> 
21:54:04.472 -> Exception (28):
21:54:04.472 -> epc1=0x4020b5cf epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
21:54:04.472 -> 
21:54:04.472 -> >>>stack>>>
21:54:04.509 -> 
21:54:04.509 -> ctx: cont
21:54:04.509 -> sp: 3ffffcd0 end: 3fffffc0 offset: 0190
21:54:04.509 -> 3ffffe60:  00000001 00000104 00000001 4020773e  
21:54:04.509 -> 3ffffe70:  00000001 3ffeffa8 3fff0330 40201f46  
21:54:04.509 -> 3ffffe80:  00000001 3ffe88bf 3fff17d4 40217070  
21:54:04.509 -> 3ffffe90:  40216a24 3fff05f0 3ffe9476 40207b7c  
21:54:04.509 -> 3ffffea0:  3ffffef0 3ffffee0 0000000c 40216e0d  
21:54:04.509 -> 3ffffeb0:  4027fb70 3ffe9404 3fff0330 0000075b  
21:54:04.509 -> 3ffffec0:  4027fb70 3ffe9404 3fff0330 40201a8c  
21:54:04.509 -> 3ffffed0:  00000000 4bc6a7f0 00000b50 00000001  
21:54:04.547 -> 3ffffee0:  00000000 00000000 4bc6a7f0 00000000  
21:54:04.547 -> 3ffffef0:  00000001 656d6f68 65704f2f 54514d6e  
21:54:04.547 -> 3fffff00:  74614754 79617765 5053455f 5345545f  
21:54:04.547 -> 3fffff10:  574c2f54 3fff0054 3fff20e4 40224010  
21:54:04.547 -> 3fffff20:  4652225b 50222c22 3fff20ac 40224a86  
21:54:04.547 -> 3fffff30:  4022af40 00000000 feefeffe feefeffe  
21:54:04.547 -> 3fffff40:  00000000 4bc6a7f0 00000b4f 00000000  
21:54:04.547 -> 3fffff50:  3fffdad0 3fff002c 3fff0e0c 402255e9  
21:54:04.585 -> 3fffff60:  4026d157 feefeffe 3fff04c0 40223b22  
21:54:04.585 -> 3fffff70:  3fff0034 3ffeffa8 3ffeffa8 00000000  
21:54:04.585 -> 3fffff80:  3fff0034 3ffeffa8 00000b4f 40205140  
21:54:04.585 -> 3fffff90:  feefeffe feefeffe feefeffe 3fff0730  
21:54:04.585 -> 3fffffa0:  3fffdad0 00000000 3fff06f0 402193c0  
21:54:04.585 -> 3fffffb0:  feefeffe feefeffe 3ffe86b8 401013b9  
21:54:04.585 -> <<<stack<<<
21:54:04.585 -> 
21:54:04.585 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
21:54:04.622 -> 
21:54:04.622 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)

....
21:54:21.692 -> W: MQTT connection...
21:54:36.718 -> W: failure_number_mqtt: 3
21:54:36.718 -> W: failed, rc=-4
21:54:36.718 -> 
21:54:36.718 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
21:54:36.718 -> 
21:54:36.718 -> Exception (9):
21:54:36.718 -> epc1=0x4020b5cf epc2=0x00000000 epc3=0x00000000 excvaddr=0x00a600a6 depc=0x00000000
21:54:36.718 -> 
21:54:36.718 -> >>>stack>>>
21:54:36.756 -> 
21:54:36.756 -> ctx: cont
21:54:36.756 -> sp: 3ffffcd0 end: 3fffffc0 offset: 0190
21:54:36.756 -> 3ffffe60:  00000003 00000000 00000001 4020773e  
21:54:36.756 -> 3ffffe70:  00000001 3ffeffa8 3fff0330 40201f46  
21:54:36.756 -> 3ffffe80:  00000001 3ffe88bf 0000032f 40100d53  
21:54:36.756 -> 3ffffe90:  3fff20ac 3fffff00 3fff0e0c 00000002  
21:54:36.756 -> 3ffffea0:  3fff20ac 00000000 00000020 40100fdb  
21:54:36.756 -> 3ffffeb0:  4022af40 2303a8c0 3fff0330 00000002  
21:54:36.756 -> 3ffffec0:  3fff20ac 3fff0e0c 3fffff00 4023495d  
21:54:36.756 -> 3ffffed0:  00000000 4bc6a7f0 000042bc 00000001  
21:54:36.790 -> 3ffffee0:  00000000 00000000 4bc6a7f0 00000000  
21:54:36.790 -> 3ffffef0:  3fff20ac 656d6f68 65704f2f 54514d6e  
21:54:36.790 -> 3fffff00:  74614754 79617765 5053455f 5345545f  
21:54:36.790 -> 3fffff10:  574c2f54 3fff0054 3fff20e4 40224010  
21:54:36.790 -> 3fffff20:  00000001 3fff0e0c 3fff20ac 40224ac7  
21:54:36.790 -> 3fffff30:  4022af40 00000000 feefeffe feefeffe  
21:54:36.790 -> 3fffff40:  00000000 4bc6a7f0 000042b9 00000000  
21:54:36.826 -> 3fffff50:  3fffdad0 3fff002c 3fff0e0c 402255e9  
21:54:36.826 -> 3fffff60:  4026d157 01656261 3fff04c0 40223b22  
21:54:36.826 -> 3fffff70:  3fff0034 3ffeffa8 3ffeffa8 00000000  
21:54:36.826 -> 3fffff80:  3fff0034 3ffeffa8 000042b9 40205140  
21:54:36.826 -> 3fffff90:  3fffdad0 00000000 3fff06f0 3fff0730  
21:54:36.826 -> 3fffffa0:  3fffdad0 00000000 3fff06f0 402193c0  
21:54:36.826 -> 3fffffb0:  feefeffe feefeffe 3ffe86b8 401013b9  
21:54:36.826 -> <<<stack<<<
21:54:36.826 -> 
21:54:36.826 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
21:54:36.863 -> 
21:54:36.863 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
21:54:36.863 -> 
21:54:36.863 -> load 0x4010f000, len 3584, room 16 

....
21:54:54.803 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
21:54:54.803 -> 
21:54:54.803 -> Exception (28):
21:54:54.803 -> epc1=0x4020b5cf epc2=0x00000000 epc3=0x00000000 excvaddr=0x04010400 depc=0x00000000
21:54:54.803 -> 
21:54:54.803 -> >>>stack>>>
21:54:54.803 -> 
21:54:54.803 -> ctx: cont
21:54:54.803 -> sp: 3ffffcd0 end: 3fffffc0 offset: 0190
21:54:54.803 -> 3ffffe60:  00000001 00000000 00000001 4020773e  
21:54:54.837 -> 3ffffe70:  00000001 3ffeffa8 3fff0330 40201f46  
21:54:54.837 -> 3ffffe80:  00000001 3ffe88bf 3fff17d4 40217070  
21:54:54.837 -> 3ffffe90:  40216a24 3fff05f0 3ffe9476 40207b7c  
21:54:54.837 -> 3ffffea0:  3ffffef0 3ffffee0 0000000c 40216e0d  
21:54:54.837 -> 3ffffeb0:  4027fb70 3ffe9404 3fff0330 0000075b  
21:54:54.837 -> 3ffffec0:  4027fb70 3ffe9404 3fff0330 40201a8c  
21:54:54.837 -> 3ffffed0:  00000000 4bc6a7f0 00000b58 00000001  
21:54:54.837 -> 3ffffee0:  00000000 00000000 4bc6a7f0 00000000  
21:54:54.872 -> 3ffffef0:  00000001 656d6f68 65704f2f 54514d6e  
21:54:54.872 -> 3fffff00:  74614754 79617765 5053455f 5345545f  
21:54:54.872 -> 3fffff10:  574c2f54 3fff0054 3fff20e4 40224010  
21:54:54.872 -> 3fffff20:  4652225b 50222c22 3fff20ac 40224a86  
21:54:54.872 -> 3fffff30:  4022af40 00000000 feefeffe feefeffe  
21:54:54.872 -> 3fffff40:  00000000 4bc6a7f0 00000b58 00000000  
21:54:54.872 -> 3fffff50:  3fffdad0 3fff002c 3fff0e0c 402255e9  
21:54:54.872 -> 3fffff60:  4026d157 feefeffe 3fff04c0 40223b22  
21:54:54.910 -> 3fffff70:  3fff0034 3ffeffa8 3ffeffa8 00000000  
21:54:54.910 -> 3fffff80:  3fff0034 3ffeffa8 00000b58 40205140  
21:54:54.910 -> 3fffff90:  feefeffe feefeffe feefeffe 3fff0730  
21:54:54.910 -> 3fffffa0:  3fffdad0 00000000 3fff06f0 402193c0  
21:54:54.910 -> 3fffffb0:  feefeffe feefeffe 3ffe86b8 401013b9  
21:54:54.910 -> <<<stack<<<
21:54:54.910 -> 
21:54:54.910 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
21:54:54.947 -> 

21:54:54.947 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
21:54:54.947 -> 
21:54:54.947 -> load 0x4010f000, len 3584, room 16 

....
21:54:57.872 -> N: ************** Setup OpenMQTTGateway end **************
21:54:57.872 -> W: MQTT connection...
21:55:12.920 -> W: failure_number_mqtt: 1
21:55:12.920 -> W: failed, rc=-4
21:55:12.920 -> 
21:55:12.920 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
21:55:12.920 -> 
21:55:12.920 -> Exception (28):
21:55:12.920 -> epc1=0x4020b5cf epc2=0x00000000 epc3=0x00000000 excvaddr=0x04010400 depc=0x00000000
21:55:12.958 -> 
21:55:12.958 -> >>>stack>>>
21:55:12.958 -> 
21:55:12.958 -> ctx: cont
21:55:12.958 -> sp: 3ffffcd0 end: 3fffffc0 offset: 0190
21:55:12.958 -> 3ffffe60:  00000001 00000000 00000001 4020773e  
21:55:12.958 -> 3ffffe70:  00000001 3ffeffa8 3fff0330 40201f46  
21:55:12.958 -> 3ffffe80:  00000001 3ffe88bf 3fff17d4 40217070  
21:55:12.958 -> 3ffffe90:  40216a24 3fff05f0 3ffe9476 40207b7c  
21:55:12.958 -> 3ffffea0:  3ffffef0 3ffffee0 0000000c 40216e0d  
21:55:12.958 -> 3ffffeb0:  4027fb70 3ffe9404 3fff0330 0000075b  
21:55:12.995 -> 3ffffec0:  4027fb70 3ffe9404 3fff0330 40201a8c  
21:55:12.995 -> 3ffffed0:  00000000 4bc6a7f0 00000b5a 00000001  
21:55:12.995 -> 3ffffee0:  00000000 00000000 4bc6a7f0 00000000  
21:55:12.995 -> 3ffffef0:  00000001 656d6f68 65704f2f 54514d6e  
21:55:12.995 -> 3fffff00:  74614754 79617765 5053455f 5345545f  
21:55:12.995 -> 3fffff10:  574c2f54 3fff0054 3fff20e4 40224010  
21:55:12.995 -> 3fffff20:  4652225b 50222c22 3fff20ac 40224a86  
21:55:12.995 -> 3fffff30:  4022af40 00000000 feefeffe feefeffe  
21:55:12.995 -> 3fffff40:  00000000 4bc6a7f0 00000b5a 00000000  
21:55:13.032 -> 3fffff50:  3fffdad0 3fff002c 3fff0e0c 402255e9  
21:55:13.032 -> 3fffff60:  4026d157 feefeffe 3fff04c0 40223b22  
21:55:13.032 -> 3fffff70:  3fff0034 3ffeffa8 3ffeffa8 00000000  
21:55:13.032 -> 3fffff80:  3fff0034 3ffeffa8 00000b5a 40205140  
21:55:13.032 -> 3fffff90:  feefeffe feefeffe feefeffe 3fff0730  
21:55:13.032 -> 3fffffa0:  3fffdad0 00000000 3fff06f0 402193c0  
21:55:13.032 -> 3fffffb0:  feefeffe feefeffe 3ffe86b8 401013b9  
21:55:13.032 -> <<<stack<<<
21:55:13.032 -> 
21:55:13.032 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
21:55:13.068 -> 
21:55:13.068 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
21:55:13.068 -> 
21:55:13.068 -> load 0x4010f000, len 3584, room 16 

Reproduced, thanks.

I’m trying to isolate the issue

Could you test with this branch please:

It should solve the issue.

Yes, I simply added the if condition around the ssl error log print sentences like your diff, with the if condition avoid the ssl error log to print, the exception disappeared.

Thanks for the feedback and the detailed reports!