Connection always successful when installed anti-virus application

When I try to use URLConnection to check if a url is accessible using the following code:

try {
    URL url = new URL("");

    URLConnection connection = url.openConnection();
    System.out.println("Connected successfully using url");
} catch (IOException e) {

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. Then I tried to use Socket to connect:

Socket socket = new Socket();
socket.connect(new InetSocketAddress("", 80));
if (socket.isConnected()) {
    System.out.println("Connected successfully using socket");
} else {
    System.out.println("Connected failed using socket");

But Still got the same problem. The solution for it: Disable http check in anti-virus, for example, in ESET NOD32, the settings is Web access protection -> Http, Https -> Http scanner http connection always success

Leave a Reply

Your email address will not be published. Required fields are marked *