HTTPS request restarts NodeMCU

1

NodeMCU Info:

> 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 

Build bin file

When I requested HTTPS request before adding the tls module it returned code -1 after I added tls module requesting HTTPS restarts the NodeMCU.

The code I used to send request.

   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)

and I tried the net module.

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

I got the same restart reason for both codes.

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

in the net moudle code the restart happens when srv:connect(443,"google.com") is called and shows one additional line RecvHold, By pespconn,find conn_msg fail

https
lua
tls1.2
nodemcu
asked on Stack Overflow Nov 24, 2018 by Mohamed Embaby • edited Nov 30, 2018 by Mohamed Embaby

2 Answers

0

Assuming the date in your error is because of something you executed recently, I suggest that you set the time to a more recent one. If your time has drifted too much your OS cannot operate normally. Set time manuelly if NTP refuse your connection. How to set RTC rtctime module, but also look at sntp module or other relevant ones.

answered on Stack Overflow Nov 27, 2018 by Gillsoft AB
0

I overcome this problem by building the same SDK Firmware 2.2.1 with Docker with the same modules and same configuration, can't control cases and lines to debug in the Cloud Build version so cant know what exactly went wrong in the Cloud Build.

The Docker Firmware info

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)
answered on Stack Overflow Nov 30, 2018 by Mohamed Embaby

User contributions licensed under CC BY-SA 3.0