Browse Source

调用超时时间设置10s

xueli.xue 8 years ago
parent
commit
09aad11fd1

+ 7 - 0
xxl-job-core/src/main/java/com/xxl/job/core/util/HttpClientUtil.java View File

@@ -2,6 +2,7 @@ package com.xxl.job.core.util;
2 2
 
3 3
 import org.apache.http.HttpEntity;
4 4
 import org.apache.http.HttpResponse;
5
+import org.apache.http.client.config.RequestConfig;
5 6
 import org.apache.http.client.methods.HttpPost;
6 7
 import org.apache.http.entity.ByteArrayEntity;
7 8
 import org.apache.http.entity.ContentType;
@@ -39,6 +40,12 @@ public class HttpClientUtil {
39 40
 				}
40 41
 				httpPost.setEntity(new UrlEncodedFormEntity(formParams, "UTF-8"));
41 42
 			}*/
43
+
44
+			// timeout
45
+			RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(10000).setConnectTimeout(10000).build();
46
+			httpPost.setConfig(requestConfig);
47
+
48
+			// data
42 49
 			if (date != null) {
43 50
 				httpPost.setEntity(new ByteArrayEntity(date, ContentType.DEFAULT_BINARY));
44 51
 			}