Tao

          Tao obeys its own inherent Nature

          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("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.

          Then I tried to use Socket to connect:

          Socket socket = new Socket();
          socket.connect(new InetSocketAddress("169.254.169.254", 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

          ESET_http_connection_always_success

          posted on 2009-07-15 13:30 wade 閱讀(470) 評論(0)  編輯  收藏 所屬分類: Java

          導航

          <2009年7月>
          2829301234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          統計

          常用鏈接

          留言簿(7)

          隨筆分類

          隨筆檔案

          相冊

          Photo

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 南投市| 海兴县| 布拖县| 阳新县| 洛扎县| 古田县| 同仁县| 新绛县| 雷州市| 平昌县| 保德县| 霍林郭勒市| 灵川县| 定结县| 鲁甸县| 松潘县| 宁远县| 湖口县| 长子县| 中西区| 于田县| 云浮市| 和平县| 清水河县| 全州县| 通化县| 吉木萨尔县| 舟曲县| 揭西县| 河曲县| 城口县| 车险| 武冈市| 绥芬河市| 民丰县| 滦南县| 霍林郭勒市| 九龙县| 都兰县| 安龙县| 德惠市|