adafruit / Adafruit_IO_Arduino

Arduino library to access Adafruit IO from WiFi, cellular, and ethernet modules.
Other
213 stars 107 forks source link

AdafruitIO_WiFi: start_ssl_client() goes in infinite loop if the AP disconnects #20

Closed fcojocaru closed 5 years ago

fcojocaru commented 6 years ago

Arduino board: Adafruit HUZZAH32 – ESP32 Feather Board Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.5

Story: I am using the Adafruit IO Temperature & Humidity Example , slightly modified ( see below ) 1) Temperature and humidity come from a BME280 so the include looks like:

#include "config.h"

#include <stdint.h>
#include "SparkFunBME280.h"
//Library allows either I2C or SPI, so include both.
#include "Wire.h"

===

Issue: A variable number of minutes after powering up the board ( but rarely longer than 30 ) the WIFI disconnects ( or the AP gets bored ).

This triggers a loop ===still working===

Temperature: 25.34C
Pressure: 102410.58Pa
[V][ssl_client.cpp:240] send_ssl_data(): Writing HTTP request...
[V][ssl_client.cpp:240] send_ssl_data(): Writing HTTP request...

===failed===

Temperature: 25.33C
Pressure: 102410.80Pa
[V][ssl_client.cpp:240] send_ssl_data(): Writing HTTP request...
[V][ssl_client.cpp:240] send_ssl_data(): Writing HTTP request...
[E][ssl_client.cpp:28] handle_error(): UNKNOWN ERROR CODE (004E)
[E][ssl_client.cpp:30] handle_error(): MbedTLS message code: -78
[V][ssl_client.cpp:209] stop_ssl_socket(): Cleaning SSL connection.
[V][ssl_client.cpp:48] start_ssl_client(): Free heap before TLS 51080
[V][ssl_client.cpp:50] start_ssl_client(): Starting socket
[V][ssl_client.cpp:86] start_ssl_client(): Seeding the random number generator
[V][ssl_client.cpp:95] start_ssl_client(): Setting up the SSL/TLS structure...
[I][ssl_client.cpp:119] start_ssl_client(): WARNING: Use certificates for a more secure communication!
[V][ssl_client.cpp:143] start_ssl_client(): Setting hostname for TLS session...
[V][ssl_client.cpp:158] start_ssl_client(): Performing the SSL/TLS handshake...
[E][ssl_client.cpp:28] handle_error(): RSA - The public key operation failed : BIGNUM - Memory allocation failed
[E][ssl_client.cpp:30] handle_error(): MbedTLS message code: -17040
[E][WiFiClientSecure.cpp:108] connect(): lwip_connect_r: 11
[V][ssl_client.cpp:209] stop_ssl_socket(): Cleaning SSL connection.
[V][ssl_client.cpp:48] start_ssl_client(): Free heap before TLS 50724
[V][ssl_client.cpp:50] start_ssl_client(): Starting socket
[V][ssl_client.cpp:86] start_ssl_client(): Seeding the random number generator
[V][ssl_client.cpp:95] start_ssl_client(): Setting up the SSL/TLS structure...
[I][ssl_client.cpp:119] start_ssl_client(): WARNING: Use certificates for a more secure communication!
[V][ssl_client.cpp:143] start_ssl_client(): Setting hostname for TLS session...
[V][ssl_client.cpp:158] start_ssl_client(): Performing the SSL/TLS handshake...
[E][ssl_client.cpp:28] handle_error(): RSA - The public key operation failed : BIGNUM - Memory allocation failed
[E][ssl_client.cpp:30] handle_error(): MbedTLS message code: -17040
[E][WiFiClientSecure.cpp:108] connect(): lwip_connect_r: 11

======

Question: Is the lower layer supposed to handle this exceptions or is the job of the upper layer libraries to treat these and trigger a reset / reconnect to wifi?

The way it looks to me ( I'm new to this so I apologize in advance ) is that a WiFi exception is never triggered and WiFiClientSecure starts looping without an exit condition ( aka 10 retries ).

Again , if this is the wrong place to open the issue , I apologize.

Thank you!

brentru commented 5 years ago

This should be fixed in the latest ESP8266 Arduino library (https://github.com/esp8266/Arduino/issues/4078).