如何使用带有请求正文参数的HTTPS POST在ESP8266中发送数据? 我尝试使用https://nodemcu.readthedocs.io提供的HTTP和net / TLS模块。 我收到这些错误
E:M 528 HTTP客户端:断开连接,错误:46
使用TLS
srv = tls.createConnection()
srv:dns(api, function(conn, ip)
api = ip
print("TLS" .. api)
end)
srv:on("receive", function(sck, c)
print(c .. "success tls")
end)
srv:on("connection", function(sck, c)
sck:send("GET /test HTTP/1.1\r\n" ..
"Host: " .. api .. "\r\n" ..
"Connection: keep-alive\r\n" ..
"Accept: */*\r\n" ..
"\r\n")
end)
srv:connect(443, "demo.com")
HTTP模块
http.post("https://demo.com/test", 'Content-Type:application/json\r\nConnection: keep-alive\r\n' { data }, function(code, data)
if (code < 0) then
print("Request Failed")
else
print(code)
print(data)
end
end)