As the title says... Chat on...

User avatar
By juanmol
#26170 hi, i'm working on this code:
Code: Select allsv=net.createServer(net.TCP, 30)
    sv:listen(sport,function(c)
      c:on("receive", function(c, pl)
        url = "/something/received/"
        print("now get " .. url)
        url_get()
      end)
    end)
function url_get()
  conn=net.createConnection(net.TCP, false)
  conn:on("receive", function(conn, pl) print(pl) end)
  conn:connect(dport,server)
  conn:send(url .. "\r\n\r\n")
  conn:close()
end

then i try it. I perfrom a get to the server at ESP8266 and in Esplorer i can see the:
"now get /something/received/"
but the execution of get_url() it's not made :(
but if i select the block inside the get_url() function, and send it with the "Block" button, it works
Why if i execute it by hand, the code is working and if is executed auto, doesn't works?
User avatar
By juanmol
#26246 nothing :( in a simplest code:
Code: Select alltmr.alarm(2,1000,1,function()
  if url ~= nil then
    print("url get")
    conn=net.createConnection(net.TCP, false)
    conn:on("receive", function(conn, pl) print(pl) end)
    conn:connect(80,192.168.33.33)
    conn:send("GET " .. url .. "\r\n\r\n")
    conn:close()
  end
  url = nil
end)
url="/hi/bye/"


it doesn't make the get :( :( :(