HTTPS请求重新启动NodeMCU

时间:2018-11-24 16:16:13

标签: https lua tls1.2 nodemcu

NodeMCU信息:

> NodeMCU custom build by frightanic.com
> branch: dev
> SSL: true
> modules: crypto,file,gpio,http,net,node,sjson,tmr,uart,wifi,tls
> powered by Lua 5.1.4 on SDK 2.2.1
> commit: d5aca39f485bf46e6d77b7fb05eaf71b8ea51bee
> Build type: integer -- tried float, same error
> LFS : disabled 

建立垃圾箱file

当我在添加HTTPS模块之前请求tls请求时,在我添加-1模块并请求tls重新启动NodeMCU之后,它返回了代码HTTPS

我用来发送请求的代码。

   print(node.heap()) -- 31824
   http.request("https://www.google.com", "HEAD", "", "", 
   function(code, data)
      if (code < 0) then
        print("HTTP request failed")
      else
        print(code, data)
      end
    end)

然后我尝试了net模块。

   print(node.heap()) -- 31824
   srv = tls.createConnection()
   srv:on("receive", function(sck, c) print(c) end)
   srv:on("connection", function(sck, c)
   sck:send("GET / HTTP/1.1\r\nHost: google.com\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")
end)
   srv:connect(443,"google.com")

两个代码的重启原因相同。

HTTP client: hostname=google.com
HTTP client: port=443
HTTP client: method=GET
HTTP client: path=/
HTTP client: DNS request
HTTP client: DNS pending
> HTTP client: DNS found google.com 172.217.18.46
client handshake start.
Fatal exception 0(IllegalInstructionCause):
epc1=0x4027ca20, epc2=0x00000000, epc3=0x00000000, excvaddr=0x402993e7, depc=0x00000000
þ
 ets Jan  8 2013,rst cause:2, boot mode:(3,x) -- sometimes x is 0, 6 or 7

load 0x40100000, len 26104, room 16 
tail 8
chksum 0xc0
load 0x3ffe8000, len 2332, room 0 
tail 12
chksum 0x3c
ho 0 tail 12 room 4
load 0x3ffe891c, len 136, room 12 
tail 12
chksum 0x56
csum 0x56

在网络模块代码中,重新启动会在调用srv:connect(443,"google.com")并显示另外一行RecvHold, By pespconn,find conn_msg fail

时发生

2 个答案:

答案 0 :(得分:0)

假设错误的日期是因为您最近执行了某项操作,因此建议您将时间设置为最近的时间。如果您的时间变化太大,则您的操作系统将无法正常运行。如果NTP拒绝您的连接,请手动设置时间。如何设置RTC rtctime module,但还要查看sntp模块或其他相关模块。

答案 1 :(得分:0)

我通过使用具有相同模块和相同配置的 Docker 构建相同的SDK Firmware 2.2.1来解决此问题,无法控制案例和生产线以在 Cloud Build < / strong>版本,因此无法知道 Cloud Build 中到底出了什么问题。

Docker固件信息

NodeMCU 2.2.0.0 built with Docker provided by frightanic.com
    branch: master
    commit: 4095c408e6a8cc9718cb06007b408d0aad15d9cd
    SSL: true
    Build type: integer
    LFS: disabled
    modules: crypto,file,gpio,http,net,node,sjson,tls,tmr,uart,wifi
 build created on 2018-11-29 17:45
 powered by Lua 5.1.4 on SDK 2.2.1(6ab97e9)