CloseableHttpClient 4.5.2中执行response = httpClient.execute(httpPost);
没有任何的等待效果,直接返回无连接,如果我想让他保持请求30秒是否可以?
RequestConfig defaultRequestConfig = RequestConfig.custom().
setConnectTimeout(30000).setConnectionRequestTimeout(30000)
.setSocketTimeout(30000).build();
// CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(defaultRequestConfig).build();
CloseableHttpResponse response = null;
String resultString = "";
HttpPost httpPost = new HttpPost(url);
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
httpPost.setConfig(defaultRequestConfig);
String uuid=UuidUtil.getuuid();
PgmsDao pgms=new PgmsDao();
LoginUI login=(LoginUI) FacesUtil.getSessionMapValue("loginUI");
String netid=login.getLdapuser().getNetid();
String request_user=login.getLdapuser().getName();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String request_date = sdf.format(new Date());
Map<String,String> request_map=(Map)new JSONObject().fromObject(json);
String action=request_map.get("action");
response = httpClient.execute(httpPost);
resultString = EntityUtils.toString(response.getEntity(), "utf-8");
String response_date = sdf.format(new Date());
Map<String,String>result=(Map)new JSONObject().fromObject(resultString);
String status=result.get("status");
如果是别的版本也可以,请大佬指点