Chat freely about anything...
User avatar
By nedoskiv
#71665 Hello,

I tried to achieve reading content from website (HTTP request) and do something depending on the response into a infinite loop, for that case I tried both NET and HTTP module , my idea is to wait into whileloop until NET or HTTP function finish work, and then decide what to do (depends on errors, etc)
but informatelly if my file is still running while NET or HTTP callback functions are executed, board reboots.
here is one code for example that do that:

Code: Select allTstart  =
print('httpget.lua started at ' .. Tstart)
print ("here is the data\n")
print (code)
code = nil
success= 0

function pause (seconds)
temptimer = + seconds
print (seconds.." pause\n")
print (temptimer.." - "
while temptimer >
print (temptimer.." - "


http.get("", nil, function(code, data)
    if (code < 0) then
--      print("HTTP request failed")
--      dofile(wifi_config_permanent.lua)
--     print(code, data)
--     dofile(wifi_config_permanent.lua)

print ("waiting for function to complete\n")
while success==0
   print (

print ("Here is the response")
print (success)

Any idea why that happen? Tried old nodemcu build, and latest one, both HTTP or NET connections, they fail in same way - never seen message "Here is the response"
User avatar
#71719 Hi!

Well, I like to develop using Arduino IDE, I think that to me, was the better choice.
I didn't know if I undestood everything about your project, but I will try to help you, but in my universe.
Check out these:
User avatar
By philbowles
#71751 CAVEAT: I'm no lua expert (I never use it) but I THINK the problem is:

while success==0
print (

While you are in that loop, the WiFi code cannot run in the background, so you are probably seeing a WDT reset. Posting the actual error message may help...

The solution is: "you can't do it that way" unfortunately I don't know the safe and recommended LUA way to do it. Anyone else?

(Apologies if I'm talking nonsense here...)