Error: DNS server IP address was not found

Hi,
can someone help me why I get error on my ChipworkX:

    #### Exception System.Exception - 0x00000000 (1) ####
    #### Message: DNS server IP address was not found.
    #### GHIElectronics.NETMF.Net.Dns::GetHostEntry [IP: 0038] ####
    #### GHIElectronics.NETMF.Net.HttpWebRequest::EstablishConnection [IP: 00e1] ####
    #### GHIElectronics.NETMF.Net.HttpWebRequest::SubmitRequest [IP: 0013] ####
    #### GHIElectronics.NETMF.Net.HttpWebRequest::GetRequestStream [IP: 0008] ####
    #### ChipworkX_XML_Test.Program::LoginRequest [IP: 0121] ####
    #### ChipworkX_XML_Test.Program::Main [IP: 0008] ####
A first chance exception of type 'System.Exception' occurred in GHIElectronics.NETMF.W5100.Http.dll
An unhandled exception of type 'System.Exception' occurred in GHIElectronics.NETMF.W5100.Http.dll

Additional information: DNS server IP address was not found.

If I run:


                Debug.Print("IP Address: " + nic.IPAddress);
                Debug.Print("Subnet Mask: " + nic.SubnetMask);
                Debug.Print("Default Getway: " + nic.GatewayAddress);
                Debug.Print("Dynamic DNS: " + nic.IsDynamicDnsEnabled);
                Debug.Print("DNS Server 1: " + nic.DnsAddresses[0]);

I get normal output:


Network settings:
IP Address: 192.168.1.201
Subnet Mask: 255.255.255.0
Default Getway: 192.168.1.1
Dynamic DNS: False
DNS Server 1: 193.189.160.13

I can also ping ChipworkX from local PC.

Code which I use when I get error:


            MemoryStream ms = new MemoryStream();
            XmlWriter xmlwrite = XmlWriter.Create(ms);

            xmlwrite.WriteProcessingInstruction("xml",
                  "version=\"1.0\" encoding=\"utf-8\"");
            xmlwrite.WriteComment("Login request");
            xmlwrite.WriteStartElement("packet");//root element
            xmlwrite.WriteStartElement("mac_address");//child element
            xmlwrite.WriteString("00-21-03-80-24-e9");
            xmlwrite.WriteEndElement();
            xmlwrite.WriteStartElement("serial");
            xmlwrite.WriteString("000000");
            xmlwrite.WriteEndElement();
            xmlwrite.WriteStartElement("hostname");
            xmlwrite.WriteString("devboard");
            xmlwrite.WriteEndElement();
            xmlwrite.WriteStartElement("model");
            xmlwrite.WriteString("mod1");
            xmlwrite.WriteEndElement();
            xmlwrite.WriteStartElement("sw_version");
            xmlwrite.WriteString("1.00");
            xmlwrite.WriteEndElement();
            xmlwrite.WriteStartElement("hw_version");
            xmlwrite.WriteString("1.00");
            xmlwrite.WriteEndElement();
            xmlwrite.WriteEndElement();//end the root element

            xmlwrite.Flush();
            xmlwrite.Close();
            //////// display the XML data ///////////
            byte[] byteArray = ms.ToArray();
            char[] cc = System.Text.UTF8Encoding.UTF8.GetChars(byteArray);
            string str = new string(cc);
            Debug.Print("Request:" + str);

            string URI = "http://www.mydomain.si/FOLDER/FILE.php";
            byte[] buffer = Encoding.UTF8.GetBytes(str);
            HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(URI);
            WebReq.Method = "POST";
            WebReq.ContentType = "text/xml";
            WebReq.ContentLength = buffer.Length;
            Stream PostData = WebReq.GetRequestStream();
            PostData.Write(buffer, 0, buffer.Length);
            PostData.Close();
            HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
            Stream Answer = WebResp.GetResponseStream();
            StreamReader _Answer = new StreamReader(Answer);
            Debug.Print("Response:" + _Answer.ReadToEnd());

Thanks for any help.

I pinged 193.189.160.13 and did not get a response.

Can you ping it?

Yes I can:

C:\Users\Dejan>ping 193.189.160.13

Pinging 193.189.160.13 with 32 bytes of data:
Reply from 193.189.160.13: bytes=32 time=27ms TTL=252
Reply from 193.189.160.13: bytes=32 time=27ms TTL=252
Reply from 193.189.160.13: bytes=32 time=27ms TTL=252
Reply from 193.189.160.13: bytes=32 time=27ms TTL=252

Ping statistics for 193.189.160.13:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 27ms, Maximum = 27ms, Average = 27ms

can you ping www.mydomain.si?

It might help if you write a simple program which just does DNS lookup.

Coul you please try another DNS server?

It seems that there is something wrong with this server. Take a look at this:

C:\Windows\System32>nslookup
Default Server:  www
Address:  10.1.10.1

> server 193.189.160.13
Default Server:  taurus-3.siol.net
Address:  193.189.160.13

> www.yahoo.com
Server:  taurus-3.siol.net
Address:  193.189.160.13

*** taurus-3.siol.net can't find www.yahoo.com: Query refused
> www.google.com
Server:  taurus-3.siol.net
Address:  193.189.160.13

*** taurus-3.siol.net can't find www.google.com: Query refused
>

193.189.160.13 Is my ISP(SIOL) DNS and looks like they have blocked others users which use other ISP…
My server is online and from firefox REST client plugin work all ok…
When Im test Im use my ISP DNS as primary DNS and for second Im use google DNS(8.8.8.8). also testing with:

IPHostEntry myIP = Dns.GetHostEntry("www.ghielectronics.com");

Has fail.
Now Im see that Im find problem…
Im using:
GHIElectronics.NETMF.Net.dll
GHIElectronics.NETMF.W5100.dll
GHIElectronics.NETMF.W5100.Http.dll
and using GHIElectronics.NETMF.Net namespace instead of System.Net … and this has been wrong and now looks like work as must…
thanks for all your answers…

Ok there is still some problems…
After cca. 100-150 http request I start receiving errors:


    #### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
    #### Message: 
    #### Microsoft.SPOT.Net.SocketNative::socket [IP: 0000] ####
    #### System.Net.Sockets.Socket::.ctor [IP: 001f] ####
    #### System.Net.HttpWebRequest::EstablishConnection [IP: 0132] ####
    #### System.Net.HttpWebRequest::SubmitRequest [IP: 0013] ####
    #### System.Net.HttpWebRequest::GetRequestStream [IP: 0008] ####
    #### MFWindowApplication1.Program::LoginRequest [IP: 0105] ####
    #### MFWindowApplication1.Program::Main [IP: 003c] ####
    #### SocketException ErrorCode = 10035
    #### SocketException ErrorCode = 10035
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in Microsoft.SPOT.Net.dll
    #### SocketException ErrorCode = 10035
    #### SocketException ErrorCode = 10035
    #### SocketException ErrorCode = 10035
    #### SocketException ErrorCode = 10035
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.Http.dll
    #### SocketException ErrorCode = 10035
    #### SocketException ErrorCode = 10035
Error!

Im try setup different DNS:
193.189.160.13
193.2.1.66
193.2.1.72
8.8.8.8
8.8.4.4

but all produce me same errors… Code which I use:


private static void LoginRequest()
        {
            try
            {
                MemoryStream ms = new MemoryStream();
                XmlWriter xmlwrite = XmlWriter.Create(ms);

                xmlwrite.WriteProcessingInstruction("xml",
                      "version=\"1.0\" encoding=\"utf-8\"");
                //  xmlwrite.WriteComment("Login request");
                xmlwrite.WriteStartElement("packet");//root element
                xmlwrite.WriteStartElement("mac_address");//child element
                xmlwrite.WriteString("00:00:00:00:00:00");
                xmlwrite.WriteEndElement();
                xmlwrite.WriteStartElement("serial");
                xmlwrite.WriteString("000000");
                xmlwrite.WriteEndElement();
                xmlwrite.WriteStartElement("hostname");
                xmlwrite.WriteString("demo");
                xmlwrite.WriteEndElement();
                xmlwrite.WriteStartElement("model");
                xmlwrite.WriteString("demo");
                xmlwrite.WriteEndElement();
                xmlwrite.WriteStartElement("sw_version");
                xmlwrite.WriteString("1.00");
                xmlwrite.WriteEndElement();
                xmlwrite.WriteStartElement("hw_version");
                xmlwrite.WriteString("1.00");
                xmlwrite.WriteEndElement();
                xmlwrite.WriteEndElement();//end the root element

                xmlwrite.Flush();
                xmlwrite.Close();
                //////// display the XML data ///////////
                byte[] byteArray = ms.ToArray();
                char[] cc = System.Text.UTF8Encoding.UTF8.GetChars(byteArray);
                string str = new string(cc);
                Debug.Print("Request:" + str);

                string URI = "http://www.server.com/API/request.php";
                byte[] buffer = Encoding.UTF8.GetBytes(str);
                HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(URI);
                WebReq.Method = "POST";
                WebReq.ContentType = "text/xml";
                WebReq.ContentLength = buffer.Length;
                Stream PostData = WebReq.GetRequestStream();
                PostData.Write(buffer, 0, buffer.Length);
                PostData.Close();
                HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
                Stream Answer = WebResp.GetResponseStream();
                StreamReader _Answer = new StreamReader(Answer);
                Debug.Print("Response:" + _Answer.ReadToEnd());
            }
            catch
            {
                Debug.Print("Error!");
            }
        }

Server is all time online and doesn’t have any problems with other devices…

For “DNS Server 1” try using your router’s IP address at 192.168.1.1

Thanks for your reply.
I think Im try it but I will try again and report if is same.

The stack trace for the exception is showing that the problem occurred in a Socket constructor. The error code of 10035 says the call would have blocked which is not clear in its meaning, but I take it to mean that the system has run out of sockets to allocate.

Check your code to see if you are leaving sockets in an open state. Change any implicit closes to explicit closes/disposes.

Mike thanks for warning… Im use one .NETMF example from net which do not close Streams and Response… Im add:

_Answer.Close();
Answer.Close();
WebResp.Close();

To end of function and looks like work ok. I will wait 1-2h and see if realy work as must…

Still work ok so this has fix problem :slight_smile: