Left here for archival purposes.

User avatar
By GeoReb
#25039 Hello boffins,

I'm using code (similar to the code below) to create a simple HTTP server.

From my browser (Chrome) I visit 192.168.4.1 and the server works as it should.
This works absolutely perfectly without fail, every time.

However, if i leave it idle for a few minuets without sending any client requests, the server hangs.
The ESP is still fully functional but the server is no longer responding to client requests and the browser is constantly waiting for a response from the ESP.

Why is this happening? Can I not send some sort of 'keepalive' packet to stop this occurring?

If I wanted to request the value of a temperature sensor for example, then this method is completely useless if it stops after just a couple minuets!?!

Code: Select allif srv then srv:close() srv=nil end
srv=net.createServer(net.TCP, 28800)
srv:listen(80,function(conn)
    conn:on("receive", function(conn,request)
        local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
        if(method == nil)then
         _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
        end
      if (vars ~= nil) then
         for t, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
            if t=="ssid" then ssid=v end
         end
      end

Any answers you may have would be much appreciated.

Many thanks,
George