So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By igor_quintal
#71378 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
Code: Select all http.begin("raspberrypi.local", 3000, "/test");
(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.

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 allhttp.begin("raspberrypi.local", 3000, "/test");
, 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.

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!
User avatar
By rudy
#71446
I have had this problem myself (as have many others)


I am still struggling with this. I have not given up yet, but I have to agree with Phil, static IP addresses are the most reliable method it seems.