Search code examples
sslhttpsesp8266nodemcu

Disconnection using HTTPS with Nodemcu


I am using the following build:

NodeMCU custom build by frightanic.com
.branch: master
.commit: c8ac5cfb912ff206b03dd7c60ffbb2dafb83fe5e
.SSL: true
.modules: file,gpio,http,i2c,net,node,spi,tmr,uart,wifi,tls
 build .built on: 2017-06-03 03:24
 powered by Lua 5.1.4 on SDK 2.1.0(116b762)

Using the http module I can succesfully make a get call:

> http.get("http://httpbin.org/ip", nil, function(code, data)
if (code < 0) then
  print("HTTP request failed")
else
  print(code, data)
end
end)>> >> 
> 200   {
"origin": "61.69.19.186"
}

Making an equivalent call using https causes a timeout:

http.get("https://httpbin.org/ip", nil, function(code, data)
if (code < 0) then
  print("HTTP request failed")
else
  print(code, data)
end
end)>> >> 

with the following messages shown on the console:

HTTP client: Disconnected with error: 9
HTTP client: Connection timeout

A couple of other similar questions from about a year ago talk about fixes required for net module and a specific version of SSL implementation required to call httpbin.org:

HTTPS (SSL) get request with NodeMCU

HTTPS get requests with NodeMCU and ESP8266

The build was created today with the TLS/SSL support by mbedTLS.


Solution

  • Rather than in a comment I'm offering this as an "answer" so the question can be closed afterwards (helps those who watch the nodemcu tag here).

    This is a known issue tracked at https://github.com/nodemcu/nodemcu-firmware/issues/1707. It seems something broke with Espressif SDK upgrade 2.0 wrt establishing secure HTTP connections.