From 94714af765326bc0567a336952b0811667b7be92 Mon Sep 17 00:00:00 2001
From: lyfO_o <764716047@qq.com>
Date: 星期三, 27 十月 2021 16:59:27 +0800
Subject: [PATCH] 货柜预警接口:alarm 字典:alarm_type 01 主电掉电,备电工作 显示:名称+地点+柜号+内容
---
src/main/java/com/nanometer/smartlab/util/HttpUtil.java | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/nanometer/smartlab/util/HttpUtil.java b/src/main/java/com/nanometer/smartlab/util/HttpUtil.java
index 38008a0..50c6a9a 100644
--- a/src/main/java/com/nanometer/smartlab/util/HttpUtil.java
+++ b/src/main/java/com/nanometer/smartlab/util/HttpUtil.java
@@ -3,16 +3,13 @@
import com.nanometer.smartlab.exception.BusinessException;
import com.nanometer.smartlab.exception.ExceptionEnumCode;
import org.apache.http.NameValuePair;
-import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
-
-import javax.swing.text.html.parser.Entity;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
@@ -25,7 +22,11 @@
CloseableHttpClient client = HttpClients.createDefault();
URIBuilder builder = new URIBuilder(url);
URIBuilder uriBuilder = builder.setParameters(params);
+
+ RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(120000)
+ .setSocketTimeout(120000).setConnectTimeout(120000).build(); //设置超时
HttpGet get = new HttpGet(uriBuilder.build());
+ get.setConfig(requestConfig);
CloseableHttpResponse res = client.execute(get);
return EntityUtils.toString(res.getEntity(), "UTF-8");
} catch (IOException | URISyntaxException e) {
--
Gitblit v1.9.2