When I try to use URLConnection to check if a url is accessible using the following code:
try { URL url = new URL("http://169.254.169.254/latest"); URLConnection connection = url.openConnection(); connection.setConnectTimeout(5000); connection.connect(); System.out.println("Connected successfully using url"); } catch (IOException e) { e.printStackTrace(); }
I expected the behavior is: connect should be success if the host is reachable, else throw exception. It works fine without the anti-virus application, but always print “connected successfully” even the host is not reachable. Continue reading “Connection always successful when installed anti-virus application”