Saturday, April 25, 2015

Problem finding the Internet

One feature of the HESA program is that it checks to see if it can connect to the internet before trying to make an update.  It does this because it will throw an error and kick out of the program if it can't write to the database because the internet is down.

There is a built-in python function to check for internet access.  The code looks like this.
urllib2.urlopen(reference, timeout=1)

The URL I use as a reference is  That IP address is supposed to be one of google's mail servers.  I figured it would be available forever.  However, about a week ago, it stopped responding to the python command and pings.

I did a quick search on the internet about the best IP address to use to test if the internet is up.  This site recommended using  That is Google's DNS server.  Another good idea is to use Open DNS's DNS server IP address.

I made simple test program that uses the urlopen function.  I sent both the 74.125 and 8.8 addresses to the function.  It could not find the internet with either address.

Then, I used the function to look for  The function found that address.  So, the python function does not work with IP addresses.

I changed the code to always look for  Now, it is seeing the internet.  Problem solved.

No comments:

Post a Comment