electronicsguy / ESP8266

ESP8266 Projects
242 stars 183 forks source link

SSL - A buffer is too small to receive or write a message #106

Closed SheetLightning closed 2 years ago

SheetLightning commented 2 years ago

I recently used this HTTPSredirect library in one of my projects to access my Google calendar. I have it working on an ESP8266, but wanted to port it to an ESP32 because the project will need the additional GPIO pins. Unfortunately I ran into a problem with Google not returning any events from my calendar. With ESP32 verbose debugging turned on, I was able to capture the following error:

Connected to Google [ 43293][V][ssl_client.cpp:369] send_ssl_data(): Writing HTTP request with 150 bytes... [ 43293][V][ssl_client.cpp:374] send_ssl_data(): Handling error -27136 [ 43299][E][ssl_client.cpp:37] _handle_error(): [send_ssl_data():375]: (-27136) SSL - A buffer is too small to receive or write a message [ 43313][V][ssl_client.cpp:324] stop_ssl_socket(): Cleaning SSL connection. gclient->GET(url, googleHost); Performed GET

The GET request is failing and not returning any data. I presume that the HTTPSredirect library somehow calls the Esspressif ssl_client module but can't see anything in the SDK except a header file. I also can't see any buffer size being set in this library as it uses a String type for the data buffer.

Can I override the size of the SSL buffer please? If so, where? I have not been able to find anything regarding this on the Expressif Github.

The code is quite straightforward and is based on this project by Andreas Spiess.

https://www.youtube.com/watch?v=sm1-l5-z3ag

I have attached a minimal example.

The error occurs when running the gclient->GET(url, googleHost); statement in my sketch. I have attached a minimal example. See the getCalendar() function.

I should probably point out that I made a minor change to the program to allow it to insert the "ESP32" string in the User-agent line in the GET and POST requests in place of "ESP8266". I don't believe this makes any functional difference, except to indicate to the Google API that the request came from an ESP32 rather than an ESP8266.

github-actions[bot] commented 2 years ago

Welcome to HTTPSRedirect! Please provide enough info to debug the issue.

SheetLightning commented 2 years ago

Sorry, posted in wrong repository. Now moved to HTTPSRequest.