Go Down

Topic: DNS Issue?! No response after successful client.connect(servername.. FTP (Read 662 times) previous topic - next topic


Dear community members,

firstly, I would like to thank to everyone who contributed to the realization of these nice arduino boards. I really appreciate the opportunity that makes microcontroller developments possible for almost everyone in a easy and low-cost way. Also big thanks to the members of this forum who provide great supports to the ones who need them.

One of my first projects is the realization of a sketch that can upload/download data to my ftp server (using the ethernet shield), which is a server i hired with a dynamic ip and a domain name.

Therefore, I used SurferTim's FTP sketch (http://playground.arduino.cc/Code/FTP).

After little adjustments, the code works perfectly. I can connect to my ftp server, download and upload. Everything just how it should be (Thank you SurferTim).

And now, here comes the big BUT....:

The sketch only works when i try to connect to the server via IP address. As I try to connect to the server by giving the domain name instead of the ip address, the sketch won't work. My Arduino Board can apparently connect to the server (since Serial.println("Command connected") happens), but there does not seem to be coming any response in to client.available(), which makes the eRcV() function in the next line to wait forever (...while(!client.available()) delay(1);...).

I have to clarifly at this point, that there is no issue with the ftp server. I can connect/download/upload to it with a Filezilla client from the same network using the domain.

Also, I noticed exactly the same issue when I try to run the WebClient example from the Arduino IDE. It is the sketch, that connects to www.google.com and prints the http response on the serial output.
This sketch also does not work if I use it as provided. There is no data coming in on client.available() and the program will disconnect a few seconds after it has established the connection.

Only, when I exchange the domain with the IP Adress of www.google.com (which I resolved just before with a dns lookup on my mac) the code works perfectly.

So I assume that there is some issue with dns. Why do I not get any data on client.available(), after I successfully connect with client.connect() using the domain name?
I don't think there is an issue with network or the server, as everything works perfectly when I unplug the ethernet cable from the arduino board and connect it to my mac, performing the same actions with applications.

I also tryed to run this code mentioned on this thread: http://forum.arduino.cc/index.php?topic=328931.0

#include <Dns.h>
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x59, 0x67 }; 

void setup() {

void loop() {

IPAddress timeServer;

  if(dns.getHostByName("www.google.com",timeServer) == 1) {
    Serial.print(F("ntp = "));
  else Serial.print(F("dns lookup failed"));



Unfortunately, I always get the "dns lookup failed" output :-(

Thank you for reading...


Don't put Ethernet.begin and dns.begin in loop. They go in setup.


Update: I could solve the problem simply by changing my internet access. It must have been some firewall issue, which blocked dns resolves.

Thank you SurferTim

Go Up