Java method isReachable is not working %100 of the time

I have a method that checks if a computer is online. IT works most of the time but sometimes it falsely says that computers are in connected.

I need to add to it so that it is more thourough. It is also important to note that it is always the same systesm that reported incorrectly. I suspect, based on the java docs, the the isReachable() method is failing due to a firewall or something.
Here is the method:

InetAddress host = InetAddress.getByName(computer);
if (!(host.isReachable(timeoutping))){
notdone = false;
Error = "Communication Error";
}catch (Exception e){notdone=false; Error= "Host not found by Name";}
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try running ur program with the proxy and port name set as
java -DhttpProxy.port=yourproxyport yourJavaClass
More reliable will be to connect to a service that you know to be running, especially since that's normally why one's interested in the first place
bbcacAuthor Commented:
same problem

Also note that i can ping these systems
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

If you're connecting thru a proxy, IT needs to be reachable as well as the true destination
bbcacAuthor Commented:
what proxy though... we use a proxy for our website, these servers are all internal to our network
>>what proxy though.

Sorry - possibly got misled by the second comment ;-)
Mayank SAssociate Director - Product EngineeringCommented:
>> I suspect, based on the java docs, the the isReachable() method is failing due to a firewall or something.

You don't have a firewall inside your company do you? I mean the systems within your system should be reachable and within the same company firewall. If it is blocked by the firewall, it won't work even a single time but looks like you said it works sometimes.

Probably try increasing your timeoutping value and see if there is a difference.
bbcacAuthor Commented:
The timeout is not the issue.  I have increased it many times. It is possible that some servers have certain ports blocked isn't it? Perhaps this is why isReachable is returning false info.

If the servers that fail may have several IP addresse, try using  InetAddress[] getAllByName(String host)  instead.
Mayank SAssociate Director - Product EngineeringCommented:
>> It is possible that some servers have certain ports blocked isn't it?

You aren't opening a socket to a port so that shoud not be a problem. If you are able tp ping, I guess that host.isReachable () should use the same.
Mayank SAssociate Director - Product EngineeringCommented: says that true ping through Java might need JNI.

Also see:

Or try connecting a socket on that remote IP with port number 7.

Otherwise you can try running ping through Runtime.getRuntime ().exec () and read the output:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.