Left here for archival purposes.

User avatar
By El42
#20357 I've done more tests, and I can confirm my idea: ESP8266 restart when PINGREQ and PUBLISH are "quite synchronous", I mean very close in timeline. In this event heap value is 5040 before restart and 4960 after restart.
I use a small delay in PUBLISH and reduce keepalive timer so the restart is more frequent.

Is it possible a collision during transmission of simultaneous messages?
User avatar
By cal
#20387 Typically the esp8266 will print information to locate program failures (exceptions) to serial.
They are written before reboot.
Maybe at 9600 or 74880 or 115200 baud. Together with exact firmware version you may be able to
see location and type of error.

Cal
User avatar
By El42
#20741 I'm using ESPlorer to upload LUA files to ESP8266.

ESP8266 restarts when PINGREQ and PUBLISH are simultaneous .

In console I see this warning before restart

Code: Select allPANIC: unprotected error in call to Lua API (sending in process)


And this is output after restart
Code: Select allNodeMCU 0.9.5 build 20150213  powered by Lua 5.1.4


This is the LUA scripts I used to replicate the error:

Code: Select allTIME_READ = 10000  -- 10 second
KEEPALIVE_PERIOD = 10 -- 10 second
sTopic = "mytest/"

function pubTemp()
 val = node.heap()
 -- publish a message with data = val, QoS = 0, retain = 0
 m:publish(sTopic.."heap",val,0,0, function(conn) print("sent "..val)
  print("tmr.time = "..tmr.time())
 end)
end

m = mqtt.Client("testESP", KEEPALIVE_PERIOD , "", "")

function reconnect()
 print("reconnecting")
 m:connect("192.168.0.7", 1883, 0, function (client)
  print("OK Reconnected")
  tmr.alarm(0,500,0,function()
    m:subscribe(sTopic.."action",0, function(conn)
     print("Resubscribe success") end) 
 end)
end)
end

function closeClient()
 m:close()
 tmr.alarm(0,1000,0,reconnect)
end

m:on("offline", function(con)
  print ("offline")
  tmr.alarm(0,1000,0,closeClient)
end)


m:connect("192.168.0.7", 1883, 0, function (client)
 print("OK connected")
 tmr.alarm(0,500,0,function()
   m:subscribe(sTopic.."action",0, function(conn)
    print("subscribe success") end) 
 end)
end)
print("start reading")
-- loop
tmr.alarm(1, TIME_READ, 1, pubTemp)
User avatar
By El42
#20852 **** UPDATE ****

I've upgraded NodeMCU firmware with lastest release :

Code: Select allNodeMCU 0.9.6 build 20150406  powered by Lua 5.1.4


and now repeating my tests there is no problem because MQTT client has changed the management of PINGREQ.
Now when the client sends a PUBLISH reset the keepalive timer so a PINGREQ message has sent only if into the keepalive period there is no PUBLISH message. I suppose that using this management of keepalive period it's very difficult to have a simultaneous transmission of PUBLISH and PINGREQ.