Open josefgull opened 3 years ago
You may need to dive bit deeper into networking basics.
the problem is that i have an nuc pc where i installed mosqitto and graphana. and i gave this pc a name(my-pc). I can reach my-pc via browser or ping. but it is not possible to use my-pc as mqtt_server in puzbsub script. i am not shure if theres any possiblity without giving my pc a static ip.
i tryed this code to look if i get an ip:
WiFi.dnsIP(dnServer); IPAddress result; int err = WiFi.hostByName(mqtt_server, result) ; if(err == 1){ Serial.print("Ip address: "); Serial.println(result); } else { Serial.print("Error code: "); Serial.println(err);
for google.com this gave back an ip for my-pc none
I am also having issues with this. This library is a dependency in a project I work with, but I'm not able to connect by just using the hostname on the same network.
My setup: i have an wifi router to wich an ubuntopc is connected running IOT-Stack and ihave my esp32 wich should send temp-data to it.
everthing works fine when i use the ip it doesnt anymore if i switch to hostname
the code is the same as from this projekt https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/
errors i get :[E][WiFiGeneric.cpp:654] hostByName(): DNS Failed for
i also tryed pinging like this
include
IPAddress ip (192, 168, 0, 102); // case1The remote ip to ping bool ret1 = Ping.ping(ip); bool ret = Ping.ping("hostname");// case2 bool ret = Ping.ping("hostname.local");// case3
it returns on in case 1 true