1、每次在进行批作业的时候,会构建http的请求
* 定时发送监控信息到质检端
*
* @return
*/
@Scheduled(fixedRate = 60000*5)
public String sendMonitorInfo() throws IOException {
List<Map> info = monitorService.getMonitorInfo();
logger.debug("monitor info{}",info);
String result = HttpUtil.doPost(sendURL,JSONArray.toJSONString(info),10000,10000);
logger.debug("send monitor result{}",result);
return result;
}
2、在请求构建完成之后,会发送请求
//发送请求
HttpResponse response = httpClient.execute(post);
HttpEntity entityReaponse = response.getEntity();
if (entityReaponse != null) {
inputStream = entityReaponse.getContent();
//转换为字节输入流
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream, Consts.UTF_8));
while ((body = br.readLine()) != null) {
result.append(body);
}
}
} catch (Throwable e) {
e.printStackTrace();
logger.error("http post error:",e);
return null;
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}
这个错应该是在 while ((body = br.readLine()) != null)方法中的,但是不知道为什么
debug的时候就显示read time out
求大神帮忙解答一下