【问题标题】:Disconnection using HTTPS with Nodemcu使用 HTTPS 和 Nodemcu 断开连接
【发布时间】:2017-11-04 12:58:56
【问题描述】:

我正在使用以下构建:

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)

使用 http 模块我可以成功地进行 get 调用:

> 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"
}

使用 https 进行等效调用会导致超时:

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

在控制台上显示以下消息:

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

大约一年前的其他几个类似问题讨论了 net 模块所需的修复以及调用 httpbin.org 所需的 SSL 实现的特定版本:

HTTPS (SSL) get request with NodeMCU

HTTPS get requests with NodeMCU and ESP8266

该版本是今天创建的,由 mbedTLS 提供 TLS/SSL 支持。

【问题讨论】:

    标签: ssl https esp8266 nodemcu


    【解决方案1】:

    我将其作为“答案”而不是在评论中提供,以便之后可以关闭问题(帮助那些在此处观看 nodemcu 标签的人)。

    这是在https://github.com/nodemcu/nodemcu-firmware/issues/1707 跟踪的已知问题。 Espressif SDK 升级 2.0 wrt 建立安全 HTTP 连接似乎有些问题。

    【讨论】:

    • 感谢您的提醒。看起来这个错误也存在于使用 SDK 1.5.4.1 的早期固件中,我下载了该固件进行检查 那是: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 由 Lua 5.1.4 on SDK 1.5.4.1(39cb9a32)Result(如果有):客户端握手开始。客户端握手失败错误:SSL 错误 80
    • 不,那是另一回事。上次我检查 httpbin.org 时使用了 2.0 之前的 Espressif SDK(axTLS 与 mbed TLS)不支持的 SNI 证书。此外,pre-2.0 仅支持只有四个密码套件的 TLS 1.1。
    【解决方案2】:

    我在使用 NodeMCU 的 ESP8266 上看到了错误 -11:

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

    在我的情况下,它有助于禁用我的路由器的防火墙(或者特别是 IP 洪水/ICMP 洪水设置)(我的应用程序突然停止工作,可能是因为路由器固件升级)。如果您无法在路由器中禁用这些设置,您可以尝试在另一个网络中测试应用程序或使用另一个路由器。

    (我知道这不能直接回答问题(对不起!),但可能会帮助其他人,他们也使用 http.get() 并收到错误代码

    【讨论】:

      猜你喜欢
      • 2017-05-21
      • 2018-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-04
      • 2021-10-17
      • 2017-07-13
      • 1970-01-01
      相关资源
      最近更新 更多