I have some trouble to configure sending GET request to apache server on Raspberry pi 3. I have configured on RPi an apache server with php scripts and mysql database (it works - checked with mozzilla). The problem is that request made from esp is not working. When i send get request i dont get any information back to ESP, and there is no new entry in database. Please check code below:
wifi.setmode(wifi.STATION)
wifi.sta.config("Huawei-dom","xxx")
ip = wifi.sta.getip()
print(ip)
tmr.alarm(1, 2000, 1, function()
if(wifi.sta.getip()~=nil) then
tmr.stop(1)
print("Connected!")
print("Client IP Addres:",wifi.sta.getip())
cl=net.createConnection(net.TCP, 0)
cl:connect(80, "192.168.8.103")
cl:on("connection", function(cl, pl) print(pl) end)
tmr.alarm(2, 5000, 1, function()
ReadDHT()
print(humi)
cl:send("GET /php/collectdata.php?humi=2 HTTP/1.1")
cl:send("Host: 192.168.8.103")
cl:send("User-Agent: curl/7.52.1")
cl:send("Accept: */*")
cl:send("")
end)
else
print("Connecting...")
end
end)