1

I have a server running at 127.0.0.1:8000 (Django application). Everything is OK, I can acces it via my browser or curl.

But when I try to connect my ESP8266 in order to send some data, something is broken, I cannot even connect to my localhost server.

I have tried:

conn = net.createConnection(net.TCP, false)
conn:on("connection", function(conn, payload) print("in connection") end)
conn:connect(8000, "127.0.0.1")

Nothing is printed.

I tried with conn:connect(8000, "localhost") , conn:connect(8000, "http://127.0.0.1") , conn:connect(80, "127.0.0.1"). Same results, nothing is printed. With the last one, I have a "DNS fail!" message.

Just to check, with conn:connect(80, "www.google.com"), "in connection" is printed.

Any guess?

asked Oct 14, 2015 at 7:30

1 Answer 1

2

In TCP/IP, the name 'localhost' or the address space staring from 127.0.0.1 to 127.255.255.255 is the local machine. Means the Machine itself. I assume your Django app works on a computer and from that computer with any browser or curl, you are able to connect and utilize the django service.

When you try to connect your django service from esp module you try to use the localhost ip which means esp module itself. Since there is nothing running on esp as a service, nothing happens.

if you want to connect esp module to django service running on your computer, you need to type your computer's real address. It should be like 192.168.1.5 or sth like that bu not starting with 127.XXXXXXXX.

Basically when you type conn:connect(8000, "localhost") you are trying to connect esp itself. Not your django on your computer.

answered Oct 15, 2015 at 9:01
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.