0

I have to distinguish "unknown host" and "host does not respond" cases in my code. I've used code:

URL url = new URL(providerURL);

try {
    if (!InetAddress.getByName(url.getHost()).isReachable(60000)) {
        System.out.println(url.getHost() + " is not reachable!");
    }
} catch (UnknownHostException e) {
    System.out.println(url.getHost() + " is unknown");
} catch (IOException e) {
     System.out.println(url.getHost() + "throws IOException!");
}

It worked for usual sites like "http://www.cnn.com" or "https://www.discountbank.co.il/DB/private/out-of-account", but for my customer site I got "Host is not reachable!" despite of the fact that in each Browser it opens customer login dialog. What was wrong?

dsolimano
  • 8,870
  • 3
  • 48
  • 63
Yury L
  • 1
  • If the site your customer can be opened, try increase your reachable ping. This would help explaining a bit on your issue: https://stackoverflow.com/questions/9922543/why-does-inetaddress-isreachable-return-false-when-i-can-ping-the-ip-address – logger Oct 05 '17 at 16:57
  • Actually, I tried to increase it to 600000 (600 sec) with same result. – Yury L Oct 08 '17 at 04:56
  • Is it possible the browser uses some proxy to reach the site? – dsolimano Jan 03 '18 at 04:35

0 Answers0