Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By jimlyke
#31365 I was wondering why an ESP8266 (NodeMCU) would work as a webclient through my residential hotspot but not through my SmartPhone hotspot? I am only doing simple HTTP GET method, but it doesn't seem to reach the website. When I edit the wifi station from the SmartPhone to the residence, it works again? I use the SmartPhone hotspot on a laptop extensively and have never seen an issue with doing all sorts of web-related things. This is really perplexing, as my code is very simple, and it seems to consistently work fine through one hotspot and not the other.

(update:) I didn't exactly find out what was wrong with my original code, but I used a slightly different piece of code, and this new code DOES work on both hotspots. Sorry to waste bandwidth but I can share at least what little I know. Here is a code sample that did NOT work on both hotspots:

conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload) print(payload) end)
conn:connect(80,"216.xxx.yyy.zzz")
conn:send("GET /oh/10/73/1 HTTP/1.1\r\n")
conn:send("Host: www.website.com\r\n\n")
conn:send("Accept: */*\r\n")
conn:send("User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n")
conn:send("\r\n")
conn:on("sent",function(conn)
print("Closing connection")
conn:close()
end)
conn:on("disconnection", function(conn)
print("Got disconnection...")

and here is the code sample that DOES work on both hotspots:

sk=net.createConnection(net.TCP, 0)
sk:on("receive", function(sck, c) print(c) end )
sk:connect(80,"216.xxx.yyy.zzz")
sk:send("GET /oh/10/73/1 HTTP/1.1\r\nHost: www.website.com\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")

the second code sample is simpler and works (and works better). I have no idea why the first does not work. I am curious if anyone has an idea, but I guess i got past my problem.