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

User avatar
By Vuden
#13780 The code below runs fine *except* that the payload I receive is only *one* character long - "H".
I know that the target website is being accessed because the page counter on it is advanced every five seconds because of my timer.alarm() loop.

I have not had this problem with payloads from other sites.

Additionally, I *am* able to scrape the entire webpage using an Arduino and an Ethernet shield.
First character is indeed "H" as in "HTTP/1.1 200 OK"

Does this have anything to do that the URL I am trying to scrape has a port number other than 80 ?

I'm stumped.
Code below.
Thank you.


Code: Select alltmr.alarm(1, 5000, 1, function()
   sk=net.createConnection(net.TCP, 0)
   sk:dns("xxx.dyndns.org",function(conn,ip)
       print("NodeMCU IP = " .. ip)
      ipnr=ip
   end) --sk:dns


   sk = nil


   conn=net.createConnection(net.TCP, 0)

   conn:on("receive", function(conn, payload)
      print(string.len(payload))
      print(payload)
      conn:close()
   end)  -- on rcv


   print("Hello")
   print("ipnr from after Hello . . " .. ipnr)


   conn:connect(8246,ipnr)

   conn:send("GET / HTTP/1.1\r\n")
   conn:send("Host: " ..   ipnr .. ":8246\r\n")
   conn:send("User-Agent: arduino-ethernet")
   conn:send("Connection: close\r\n")
   conn:send("\r\n\r\n")
 
end) --