I have a NodeMCU Lua application that uses two timers. Each timer invokes a function that causes an HTTP request to be made to a local server.
After a few iterations, one of the timers stops, and the other timer continues. The number of iterations before the timer stops seems to be random. I have run the test script many times and the point at which the timer stops is never the same. Note: it is not always the same timer that halts.
Here is some test code that reliably demonstrates this problem:
ctr1=0
ctr2=0
local function doCmdChk()
ctr1 = ctr1 + 1
http.get( "http://192.168.2.38/ICmd.py?i=" .. ctr1 , nil,
function(rspCode, payload)
tmr.start(1)
end)
end
local function sendData()
ctr2 = ctr2 + 1
local msgBdy = '{"s":"' .. ctr2 .. '","i":"test23", "d":"heap='..node.heap()..'"}'
http.post("http://192.168.2.38/DeviceScan.py", "Content-Type: text/json\r\n", msgBdy,
function(rspCode, payload)
tmr.start(2)
end)
end
--mainline start:
tmr.alarm(1, 3000, tmr.ALARM_SEMI, doCmdChk)
tmr.alarm(2, 5000, tmr.ALARM_SEMI, sendData)
My application doesn't fire off the HTTP requests as quickly as the test code, but when the application runs for several hours the same result eventually occurs (i.e. one of the timers stops running). Reducing the time between HTTP requests makes the error occur sooner.
Has anyone encountered this issue? Does anyone have any ideas as to how to troubleshoot this issue? (not being able to reliably send continuous HTTP requests is a show stopper for this application).