Showing
2 changed files
with
18 additions
and
2 deletions
| ... | ... | @@ -15,6 +15,7 @@ import org.apache.http.client.methods.CloseableHttpResponse; |
| 15 | 15 | import org.apache.http.client.methods.HttpPost; |
| 16 | 16 | import org.apache.http.entity.ContentType; |
| 17 | 17 | import org.apache.http.entity.StringEntity; |
| 18 | +import org.apache.http.client.config.RequestConfig; | |
| 18 | 19 | import org.apache.http.impl.client.CloseableHttpClient; |
| 19 | 20 | import org.apache.http.impl.client.HttpClients; |
| 20 | 21 | import org.apache.http.message.BasicHeader; |
| ... | ... | @@ -196,7 +197,14 @@ public class DjxcDevicePullService { |
| 196 | 197 | } |
| 197 | 198 | |
| 198 | 199 | private String sendPost(HttpPost httpPost, String jsonData) { |
| 199 | - CloseableHttpClient httpClient = HttpClients.createDefault(); | |
| 200 | + RequestConfig requestConfig = RequestConfig.custom() | |
| 201 | + .setConnectTimeout(10000) | |
| 202 | + .setSocketTimeout(30000) | |
| 203 | + .setConnectionRequestTimeout(10000) | |
| 204 | + .build(); | |
| 205 | + CloseableHttpClient httpClient = HttpClients.custom() | |
| 206 | + .setDefaultRequestConfig(requestConfig) | |
| 207 | + .build(); | |
| 200 | 208 | StringEntity entity = new StringEntity(jsonData, ContentType.create("application/json", Consts.UTF_8)); |
| 201 | 209 | httpPost.setEntity(entity); |
| 202 | 210 | String result = null; | ... | ... |
| ... | ... | @@ -15,6 +15,7 @@ import org.apache.http.client.methods.CloseableHttpResponse; |
| 15 | 15 | import org.apache.http.client.methods.HttpPost; |
| 16 | 16 | import org.apache.http.entity.ContentType; |
| 17 | 17 | import org.apache.http.entity.StringEntity; |
| 18 | +import org.apache.http.client.config.RequestConfig; | |
| 18 | 19 | import org.apache.http.impl.client.CloseableHttpClient; |
| 19 | 20 | import org.apache.http.impl.client.HttpClients; |
| 20 | 21 | import org.apache.http.message.BasicHeader; |
| ... | ... | @@ -196,7 +197,14 @@ public class WwnjDevicePullService { |
| 196 | 197 | } |
| 197 | 198 | |
| 198 | 199 | private String sendPost(HttpPost httpPost, String jsonData) { |
| 199 | - CloseableHttpClient httpClient = HttpClients.createDefault(); | |
| 200 | + RequestConfig requestConfig = RequestConfig.custom() | |
| 201 | + .setConnectTimeout(10000) | |
| 202 | + .setSocketTimeout(30000) | |
| 203 | + .setConnectionRequestTimeout(10000) | |
| 204 | + .build(); | |
| 205 | + CloseableHttpClient httpClient = HttpClients.custom() | |
| 206 | + .setDefaultRequestConfig(requestConfig) | |
| 207 | + .build(); | |
| 200 | 208 | StringEntity entity = new StringEntity(jsonData, ContentType.create("application/json", Consts.UTF_8)); |
| 201 | 209 | httpPost.setEntity(entity); |
| 202 | 210 | String result = null; | ... | ... |