Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32: https request no longer works #1613

Open
wilberforce opened this issue Feb 4, 2019 · 9 comments

Comments

Projects
None yet
5 participants
@wilberforce
Copy link
Member

commented Feb 4, 2019

See:

http://forum.espruino.com/conversations/330049/#comment14604279

var http = require("http");
http.get("https://www.google.com", function(res) {
  res.on('data', function(data) {
    console.log(data);
  });
});
Uncaught InternalError: Failed! mbedtls_ssl_setup: Not enough memory

@wilberforce wilberforce added the ESP32 label Feb 4, 2019

@GabrielGab

This comment has been minimized.

Copy link

commented Feb 9, 2019

yes , I have verified same problem on version 2.01 for ESP32 but ESP8266 still working fine for https, on same version.

@wilberforce

This comment has been minimized.

Copy link
Member Author

commented Feb 12, 2019

Working:

>process.env
={
  "VERSION": "1v97",
  "GIT_COMMIT": "74b2511",
  "BOARD": "ESP32",
  "FLASH": 0, "RAM": 524288,
  "SERIAL": "240ac400-2f90",
  "CONSOLE": "Serial1",
  "MODULES": "Flash,Storage,fs," ... "r,crypto,neopixel",
  "EXPTR": 1073417244 }
> 

{ "free": 2601, "usage": 2399, "total": 5000, "history": 53,
  "gc": 0, "gctime": 2.061 }
E (64222) esp_ota_ops: ota data invalid, no current app. Assuming factory
{
  "sdkVersion": "v2.1",
  "freeHeap": 129480, "addr": 65536,
  "partitionBoot": "factory"
 }


Fail:

process.env
={
"VERSION": "1v98",
"GIT_COMMIT": "1e06400",
"BOARD": "ESP32",
"FLASH": 0, "RAM": 524288,
"SERIAL": "240ac400-2f90",
"CONSOLE": "Serial1",
"MODULES": "Flash,Storage,fs," ... "r,crypto,neopixel",
"EXPTR": 1073485304 }
ESP32.getState()
={
"sdkVersion": "v3.0",
"freeHeap": 37668 }


Current:

>   console.log(process.env);
{
  "VERSION": "2v01.33",
  "GIT_COMMIT": "adb3b7d",
  "BOARD": "ESP32",
  "FLASH": 0, "RAM": 524288,
  "SERIAL": "240ac400-2f90",
  "CONSOLE": "Serial1",
  "MODULES": "Flash,Storage,heatshrink,fs,net,dgram,tls,http,NetworkJS,Wifi,TelnetServer,crypto,neopixel",
  "EXPTR": 1073484860 }
=undefined
{ "free": 3965, "usage": 135, "total": 4100, "history": 17,
  "gc": 0, "gctime": 3.262 }
=undefined
>  console.log( ESP32.getState());
{
  "sdkVersion": "v3.1.2-dirty",
  "freeHeap": 20412, "BLE": false, "Wifi": true, "minHeap": 10984 }
=undefined


@wilberforce

This comment has been minimized.

Copy link
Member Author

commented Feb 12, 2019

Got this working by reducing jsvars. The current esp-idf build is using more heap. Looking at reducing the dynamic buffers - also set to 16 top buffers when 10 in the past.

@gfwilliams

This comment has been minimized.

Copy link
Member

commented Feb 12, 2019

Normal Espruino builds actually allocate space for HTTPS out of JsVars and that was disabled for ESP32 - potentially that could be re-added I guess?

@jumjum123

This comment has been minimized.

Copy link
Contributor

commented Feb 12, 2019

@wilberforce, did you check minHeap in ESP32.getState ?
In theory, this should show minimum size of free heap, happened sometime during execution
Idea was to use this to adjust number of jsvars
freeHeap is 37 kb, which is a lot.

@wilberforce

This comment has been minimized.

Copy link
Member Author

commented Feb 12, 2019

Ah - thanks - that explains it.
I think that when @jumjum123 changed to use the esp-idf version on mbedTLS that was lost. This was due to the esp-odd version being several versions ahead of the version use in espruino and there where missing functions and it would not compile.

@wilberforce

This comment has been minimized.

Copy link
Member Author

commented Feb 12, 2019

@jumjum123 - I don't think free heap is that large on the current travis build - perhaps 32k.

I also recall there was a https buffer size setting in espruino - as the default is something like 15k.

A bit more reseach!

@wilberforce

This comment has been minimized.

Copy link
Member Author

commented Feb 13, 2019

Looking at the available heap in the versions above v2 has much more heap than v3!

It looks like the callow used can be changed here:

https://github.com/espressif/esp-idf/blob/master/components/mbedtls/Kconfig

And the buffer size from 16k to 512 and also turn off suites not used to match the espruino/mdebtls/config.h

@MaBecker

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2019

@GabrielGab

but ESP8266 still working fine for https, on same version.

Nice, do you like to share some details using https with ESP8266?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.