i want to use the sk:send from other functions too :/
Edit : rather than dofile("functions.lua") i used the require"functions" and it did the job.. now my functions are created while socket created and works like charm
Explore... Chat... Share...
cendev wrote:Edit : rather than dofile("functions.lua") i used the require"functions" and it did the job.. now my functions are created while socket created and works like charm
zeroday wrote:xinort wrote:I'm not sure if this is the best place to ask this but I'm using the lua web server and running into a problem. I can connect but only 2 times before I get a MAX_SOCKET error. I can't figure out how to release the socket after sending the data. I've tried conn:close() but no joy. This is the lua script I'm trying to use:Code: Select allsrv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive",function(conn,payload)
print(payload)
door="open"
if gpio.read(8)==1 then door="open" else door="closed" end
conn:send("<h1> Door Sensor. The door is " .. door ..".</h1>")
conn:close()
end)
end)
MAX_SOCKET is 5.
A connection will closed in 180 seconds if it's inactive.
I will do more test on net module to find out why conn:close() doesn't work.
My experience is a Chrome will initiate 3 or 4 connections to host, if click on "refresh" too fast, the MAX_SOCKET is reached easily.
srv=net.createServer(net.TCP) srv:listen(80,function(conn)
conn:on("receive",function(conn,payload)
print(node.heap())
door="open"
if gpio.read(0)==1 then door="open" else door="closed" end
conn:send("<h1> Door Sensor. The door is " .. door ..".</h1>")
end)
conn:on("sent",function(conn) conn:close() end)
end)
zeroday wrote:zeroday wrote:xinort wrote:I'm not sure if this is the best place to ask this but I'm using the lua web server and running into a problem.
this bug is fixed.
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\n\n")
conn:send("<html><body>")
conn:send("<h1>Served from GWR's ESP8266</h1><BR>")
conn:send("NODE.CHIPID : " .. node.chipid() .. "<BR>")
conn:send("NODE.HEAP : " .. node.heap() .. "<BR>")
conn:send("TMR.NOW : " .. tmr.now() .. "<BR>")
conn:send("</html></body>")
conn:on("sent",function(conn) conn:close() end)
end)
end)
It takes about 20-25 seconds for home assistant c[…]
I tried to upgrade tof my sonoff basic R2 with the[…]
a problem Perhaps you want to define "Probl[…]
Rebooting your router will not give you a faster I[…]
There are no other notifications from esptool.py i[…]
Using the Arduino IDE, you'll learn how to set up […]
In this project, you will post to Twitter using an[…]
In this project, we will build a water level contr[…]
I guess I'm late, but I had the same problem and f[…]
Last night I received my first D1 Minis for a lear[…]
Although I am aware that this is an old post, I fe[…]