问题出现

主机调用异常:I/O error on POST request for "http://127.0.0.1:8181/api/xxxxxx/xxxxx": Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out

问题处理

出问题的代码

ResponseEntity<String> response = dispatcherRestTemplate.postForEntity(url, rptResource.getParamJson(), String.class);

延长的读取时间

@Configurationpublic class RestTemplateConfig {/** * 调度器使用的RestTemplate,超时5s * @return */@Bean("dispatcherRestTemplate")public RestTemplate getRestTemplate(){RestTemplate restTemplate = new RestTemplateBuilder().setConnectTimeout(200000).setReadTimeout(200000).build();//解决中文乱码List<HttpMessageConverter<?>> msgConv = restTemplate.getMessageConverters();if(msgConv != null && !msgConv.isEmpty()) {for(int i = 0; i < msgConv.size(); i++ ){if(msgConv.get(i).getClass().equals(StringHttpMessageConverter.class)) {msgConv.set(i, new StringHttpMessageConverter(StandardCharsets.UTF_8));}}}return restTemplate;}}