Access server by hostname and not IP (mDNS)
Posted: Sun Oct 29, 2017 9:58 pm
Hi everyone!
I'm working on a project which connects a NodeMCU to a Raspberry Pi, which is operating as a server. I want to make requests to the Raspberry from the NodeMCU without knowing its IP address. The Raspberry host name is simply "raspberrypi", and I'm able to make requests using this hostname through Postman or any other browsers. Now I want to make these requests using NodeMCU (I'm using ESP libraries). What I want to do is that my requests depends only on a hostname, and not an IP (because the router may change it, and the service cannot stop working). But something really strange is happening.
If I use my own WiFi (provided by a router), and try
But what is really strange is that if I start a HotSpot with my Android phone, and connect the NodeMCU and the Raspberry, and try
The Raspberry is running Avahi, but things don't work unless I'm on my Android hotspot (I tested other WiFi networks with no success). I really need this functionality to work on my project, or anything that makes it no dependable on IP addresses. Is there anyway someone could help me out?
Thanks!
I'm working on a project which connects a NodeMCU to a Raspberry Pi, which is operating as a server. I want to make requests to the Raspberry from the NodeMCU without knowing its IP address. The Raspberry host name is simply "raspberrypi", and I'm able to make requests using this hostname through Postman or any other browsers. Now I want to make these requests using NodeMCU (I'm using ESP libraries). What I want to do is that my requests depends only on a hostname, and not an IP (because the router may change it, and the service cannot stop working). But something really strange is happening.
If I use my own WiFi (provided by a router), and try
Code: Select all
(I have also tried without the ".local" with no success), I cannot access the server, I get an error. If I use raspberry's IP address, it works perfectly. http.begin("raspberrypi.local", 3000, "/test");
But what is really strange is that if I start a HotSpot with my Android phone, and connect the NodeMCU and the Raspberry, and try
Code: Select all
, it works with no problem!! I read that this is about mDNS, and I have also tried using this library https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266mDNS with no success.http.begin("raspberrypi.local", 3000, "/test");
The Raspberry is running Avahi, but things don't work unless I'm on my Android hotspot (I tested other WiFi networks with no success). I really need this functionality to work on my project, or anything that makes it no dependable on IP addresses. Is there anyway someone could help me out?
Thanks!