Cannot connect anymore with ESP32 (bug solved!))

Hi,
I am completely baffled and stuck since two days:
I cannot connect any more with ESP32 devices (I tried several ones)
Everything compiles without a single error, even verbose and with all warnings on.

Using library thinger.io at version 2.16.0 in folder: D:\5_Tinker\Arduino\libraries\thinger.io
Using library WiFiClientSecure at version 1.0 in folder: C:\Users\Laszlo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\WiFiClientSecure
Using library WiFi at version 1.0 in folder: C:\Users\Laszlo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\WiFi

(all libraries rebuilt from scratch)
They connect correctly to Wifi, but upon trying to access Thinger, the connection cannot be established.
Even using the bare Thinger ESP 32 example, i get this debug message:

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5856
entry 0x400806a8
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 0 - WIFI_READY
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 4 - STA_CONNECTED
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:419] _eventCallback(): STA IP: 192.168.188.70, MASK: 255.255.255.0, GW: 192.168.188.1
[V][ssl_client.cpp:265] stop_ssl_socket(): Cleaning SSL connection.
[V][ssl_client.cpp:59] start_ssl_client(): Free internal heap before TLS 280908
[E][WiFiClientSecure.cpp:133] connect(): start_ssl_client: -1
[V][ssl_client.cpp:265] stop_ssl_socket(): Cleaning SSL connection.
[V][ssl_client.cpp:265] stop_ssl_socket(): Cleaning SSL connection.
[V][ssl_client.cpp:59] start_ssl_client(): Free internal heap before TLS 280908
[E][WiFiClientSecure.cpp:133] connect(): start_ssl_client: -1
[V][ssl_client.cpp:265] stop_ssl_socket(): Cleaning SSL connection
... looping continuously

I tried uninstalling the IDE completely, removing all libraries and reinstalling from scratch including Thinger : nothing helps.
I am 100% sure of my credentials. I have redone the Thinger device twice and sketches for ESP8266 work flawlessly with the same credentials.
Have you got a clue how to get out of that mess?

I’m afraid to mention that we probably have a generic problem:
I have now used a pristine computer, windows 10 reset to defaults, updated.
-freshly installed the latest Arduino IDE 1.8.13
-installed the boards ESP32 and ESP8266 from the board manager.
-installed thinger.io from the library manager.
Nothing else!
-Called the thinger.io ESP32 example from the library.
-Entered my credentials that work with an ESP8266
-Compiled without error (verbose, all warnings on), loaded the code on a fresh Wemos32 board.
Upon running, I get exactly the same diagnostic messages mentioned above and the console device never connects.

I can’t imagine something wrong on my side now!.

Could you have a certificate that ran out?

Not sure if this is the case.
When I try to connect my MKR to thinger.io, I need to first upload the thinger SSL certificate to WiFi module, and I need to do it again after reinstalling the Arduino IDE.
Have you repeat the procedure on the documentations (ARDUINO - Thinger.io Documentation) after initializing the device?

Ouch! there is a difference, indeed that I have overseen:
Thinger.io recommends
https://dl.espressif.com/dl/package_esp32_index.json
I have the current path from github:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

The versions are the same: 1.0.6.
Let us see if the different sources make a difference…

By the way: there is a small glitch in the documentation of the ESP32 part:

It should be:
Next, go to the Boards manager to install the ESP32 package. Search for the esp32 and install the package **esp32 by Espressif systems **

No, i have changed the source string; removed the board, reinstalled the board using the string from the doc.
Same results:
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:10944
load:0x40080400,len:6388
entry 0x400806b4
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 0 - WIFI_READY
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 4 - STA_CONNECTED
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:419] _eventCallback(): STA IP: 192.168.188.76, MASK: 255.255.255.0, GW: 192.168.188.1
[V][ssl_client.cpp:265] stop_ssl_socket(): Cleaning SSL connection.
[V][ssl_client.cpp:59] start_ssl_client(): Free internal heap before TLS 281100
[E][WiFiClientSecure.cpp:133] connect(): start_ssl_client: -1
[V][ssl_client.cpp:265] stop_ssl_socket(): Cleaning SSL connection.
[V][ssl_client.cpp:265] stop_ssl_socket(): Cleaning SSL connection.
[V][ssl_client.cpp:59] start_ssl_client(): Free internal heap before TLS 281104
[E][WiFiClientSecure.cpp:133] connect(): start_ssl_client: -1
[V][ssl_client.cpp:265] stop_ssl_socket(): Cleaning SSL connection.

the last repeats every 2-3 seconds…

Hi @rin67630, this seems to be a problem related with upgraded ESP32 core libraries regarding SSL connections. I have a beta ESP32 version working, but in the meanwhile, you should set the following line at the very beginning of your sketch, before any other include.

#define _DISABLE_TLS_

Hope it helps! Will keep you updated once fixed…

Thank you Alvaro.
Apparently a workaround should be to patch the ESP device with these older WiFiClientSecure files:

I did not test yet, but the maintainers at GitHub seem to have been informed.

I have it solved with code in Thinger.io so no need to patch anything in ESP32. It is basically the same workaround as present in the ESP8266. I will release it next week. In the meanwhile you can develop without using SSL…

1 Like

Thank you. :heart: :heart: :heart:

You may want to correct the small glitch in your documentation as well:
By the way: there is a small glitch in the documentation of the ESP32 part:

It should be:
Next, go to the Boards manager to install the ESP32 package. Search for the esp32 and install the package **esp32 by Espressif systems **

Finally the ESP workaround is ridiculously simple:

Go to the boards manager,


select version 1.0.4 (instead of 1.0.6)
Install.
Recompile.

Yeeep!
:yum:

Regards
Laszlo

1 Like