Simple Web Server crash
Posted: Wed Feb 25, 2015 7:10 am
Hello,
I am trying to run a very simple web server on the ESP8266 with the latest version of the NodeMcu firmware. Here is the code:
It works once, without problems, then I need to reset the ESP8266 because it gets stuck. I tried to play with HTTP headers, same issue. Anyone know what the bug is? Thanks!
I am trying to run a very simple web server on the ESP8266 with the latest version of the NodeMcu firmware. Here is the code:
Code: Select all
srv = net.createServer(net.TCP)
srv:listen(80, function(conn)
conn:on("receive",function(conn, payload)
print(payload)
conn:send("HTTP/1.1 200 OK\r\n")
conn:send("Connection:keep-alive\r\n")
conn:send("Cache-Control: private, no-store\r\n\r\n")
conn:send("<h1> Hello, NodeMcu.</h1>")
conn:on("sent", function(conn) conn:close() end)
end)
end)
It works once, without problems, then I need to reset the ESP8266 because it gets stuck. I tried to play with HTTP headers, same issue. Anyone know what the bug is? Thanks!