Help with Web requests not working
Posted: Fri Jan 23, 2015 11:38 am
I hope someone can help as I'm pulling my hair out trying to get this to work. I'm using the LuaUploader and when the following code is executed it works just fine:
But when i try to execute the above from a function or in a file it doesn't work. For example if I write the above to a file called test.lua and then run the following in the immediate window or from within init.lua nothing happens.
Does anyone have any idea what i'm doing wrong?
PS. I'm running: NodeMcu 0.9.5 build 20150105 powered by Lua 5.1.4
Thanks
Code: Select all
require('net')
conn=net.createConnection(net.TCP, 1)
conn:on("receive", function(conn, payload) print(payload) end )
conn:connect(443,"108.59.13.232")
conn:send("GET /1/messages.json HTTP/1.1\r\n")
conn:send("Host: api.pushover.net\r\n")
conn:send("Pragma: no-cache\r\n")
conn:send("Cache-Control: no-cache\r\n")
conn:send("Content-Type: application/x-www-form-urlencoded\r\n")
conn:send("Accept: */*\r\n\r\n")
conn:close()
But when i try to execute the above from a function or in a file it doesn't work. For example if I write the above to a file called test.lua and then run the following in the immediate window or from within init.lua nothing happens.
Code: Select all
dofile("test.lua")
Does anyone have any idea what i'm doing wrong?
PS. I'm running: NodeMcu 0.9.5 build 20150105 powered by Lua 5.1.4
Thanks