Post topics, source code that relate to the Arduino Platform
User avatar
By bdollerup
#72242 I'm trying to not use static ip addresses for my MQTT server by using the hostByName.

When I use the command to get the ip address of an external (nttp) server, the command returns the ip address of the server just fine, but when I use the same command to get an ip address of a host on my LAN, it fails to get the ip address.

Here my code:

const char* mqttServerName ="servername";
IPAddress mqttServerIP;

WiFi.hostByName(mqttServerName, mqttServerIP)

What did I do wrong?

User avatar
By QuickFix
#72253 Do you have a DNS or Bonjour running inside your LAN? :idea:
User avatar
By rudy
#72254 External names are resolved by external DNS servers. What is inside your private network is not available to external servers so you need to add a mechanism in your network for that to work.

For Mac OSX support is built in through Bonjour already.
For Linux, install Avahi.
For Windows, install Bonjour.