Spring Rest模板超时不适用于下载pdf文件

时间:2018-06-11 18:30:01

标签: rest

我尝试将超时设置为休息模板,如下面的1和2.它是随机工作的,有时读取时间在9秒后失败但有时我会在10-11秒后得到响应。是否有任何具体原因导致超时不能持续工作下载文件。我正在下载最大1.5MB的文件

1.RestTemplate srestTemplate = new RestTemplate();             HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();             factory.setReadTimeout(9000);             factory.setConnectTimeout(9000);             factory.setConnectionRequestTimeout(9000);             srestTemplate.setRequestFactory(工厂); 2.RequestConfig config = RequestConfig.custom()                     .setSocketTimeout(9000)                     .setConnectTimeout(9000)                     .setConnectionRequestTimeout(9000).build();

        CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(connectionManager)
                .setDefaultRequestConfig(config).build();

        restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory(httpClient));

0 个答案:

没有答案