【发布时间】:2019-04-26 20:29:51
【问题描述】:
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
当我在添加tls 模块之前请求HTTPS 请求时,它在我添加tls 模块请求HTTPS 后返回代码-1 重新启动NodeMCU。
我用来发送请求的代码。
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
在 net moudle 代码中,当调用 srv:connect(443,"google.com") 时会发生重新启动并显示另外一行 RecvHold, By pespconn,find conn_msg fail
【问题讨论】:
-
我对@987654333@ 失败并不感到惊讶,因为 Google 返回的数据量远远超过设备堆的容量。但是,
http.request("https://www.google.com", "HEAD"不应该发生这种情况,因为没有返回任何有效负载。 -
@MarcelStör
http.request("https://www.google.com", "HEAD"在这种情况下应该至少返回 200 的响应代码,我尝试与其他站点相同的结果,虽然我克服了这个问题,请参阅答案 -
嗯,这正是我所说的,“无负载”-> 只有 HTTP 标头。