Browse Source

设置超时时间

yumeng 5 năm trước cách đây
mục cha
commit
38010c1876

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/HttpUtils.java

@@ -340,11 +340,14 @@ public class HttpUtils {
         String strReturn = "";
         try {
             HttpPost httppost = new HttpPost(url);
+            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(12000).setConnectTimeout(12000).build();
+            httppost.setConfig(requestConfig);
             if (!Check.isNullMap(headers)) {
                 for (String key : headers.keySet()) {
                     httppost.setHeader(key, headers.get(key));
                 }
             }
+
             httppost.setHeader("User-Agent", USER_AGENT);
             if (!Check.isNull(body)) {
                 httppost.setEntity(new StringEntity(body, Charset.forName("UTF-8")));