소스 검색

设置超时

njs 1 년 전
부모
커밋
609e553669
1개의 변경된 파일2개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      suishenbang-common/src/main/java/com/dgtly/common/utils/http/HttpUtils.java

+ 2 - 0
suishenbang-common/src/main/java/com/dgtly/common/utils/http/HttpUtils.java

@@ -61,6 +61,8 @@ public class HttpUtils
             connection.setRequestProperty("accept", "*/*");
             connection.setRequestProperty("connection", "Keep-Alive");
             connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+            connection.setConnectTimeout(10000);
+            connection.setReadTimeout(10000);
             connection.connect();
             in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
             log.info("read success url- {}", realUrl);