0

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.

mhaselup
  • 228
  • 2
  • 9

2 Answers2

0

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.

Marcel Stör
  • 22,695
  • 19
  • 92
  • 198
  • Thanks for the heads up. Looks like this bug is also present in the earlier firmware using SDK 1.5.4.1 which I downloaded to check That is: NodeMCU custom build by frightanic.com .branch: 1.5.4.1-final .commit: 1885a30bd99aec338479aaed77c992dfd97fa8e2 .SSL: true .modules: file,gpio,http,i2c,net,node,spi,tmr,uart,wifi,tls build .built on: 2017-06-07 06:01 powered by Lua 5.1.4 on SDK 1.5.4.1(39cb9a32)Result(if any): client handshake start. client handshake failed Error: SSL error 80 – mhaselup Jun 07 '17 at 06:58
  • No, that's something else. When last I check httpbin.org uses a SNI certificate which is not supported by the pre-2.0 Espressif SDKs (axTLS vs. mbed TLS). Also, pre-2.0 only supports TLS 1.1 with only four cipher suites. – Marcel Stör Jun 07 '17 at 10:41
0

I saw the Error -11 on an ESP8266 using NodeMCU:

HTTP client: Disconnected with error: -11
HTTP client: Connection timeout

In my case, it helped to disable the firewall (or specifically, the IP flood/ICMP flood setting) of my router (my application stopped working out of nowhere, presumably because of a router firmware upgrade). If you can't disable these settings in your router, you might try to test the application in another network or using another router.

(I know this doesn't directly answer the question (sorry!) but might help other people, who also use http.get() and receive an error code < 0 like the author of the question.)

Matthias Luh
  • 503
  • 6
  • 11