GHI Spider freezes when DNS.GetHostEntry loops in DNS requests

Hi,

I have written a code to use NTP to update the Spider clock. The first step is to get the IP address of the NTP server using a DNS request and the name of the NTP server.

The spider is connected to a router using a WIFI RS21 module. The routeur is connected to internet using a DSL line. The connection between the Spider and the router never fails, so the Spider always thinks it’s connected. But the DSL line sometimes fails and the DNS servers become unreachable.

The problem is that if the DSL line fails, the DNS.GetHostEntry seems to loop and starts to slow down the entire Spider so that it seems freezed, even though I have put the Network components in a separate thread.

Have you ever seen such a behavior ? Do you have a solution to this problem ?

Thanks.

Stephan.

Here is a code I use :


            try
            {
                NTPTime.PrimaryServer = Dns.GetHostEntry(primaryNTPServer).AddressList[0].GetAddressBytes();
                NTPTime.AlternateServer = Dns.GetHostEntry(secondaryNTPServer).AddressList[0].GetAddressBytes();
            }
            catch (Exception e)
            {
                DebugService.Print("NTPService : Exception on DNS lookup for NTP servers address");
                DebugService.Print(e.Message);
            }

1 Like

Thanks !

Well, that sounds exactly like the behavior I see. Which is reasuring as I know now what my problem is about.

I looked at the code you shared and it looks like it assumes that the DNS request will work as it is the very first call done, which is the call that fails and blocks my Spider.

So, I need to find a way to test the availability of the DNS server, before calling DNS.GetHostEntry, and without blocking the spider…

It looks like I can ping the DNS server and get a response. That’s a begining.

Can you share the piece of code you use to start a thread and kill it after a few seconds if nothing happens, or leave it alive in case of success ?

Thanks again?

Stephan.