Setting timeouts in Spring Rest Template

后端 未结 3 1553
别跟我提以往
别跟我提以往 2021-01-15 03:15

Application is using Spring rest template to call a webservice and i am using
restTemplate.exchage(url) to call the webservice. Currently we are not passing any

3条回答
  •  庸人自扰
    2021-01-15 04:08

    I use this approach based on these threads

    int DEFAULT_TIMEOUT = 5000;
    RequestConfig requestConfig = RequestConfig.custom()
     .setConnectTimeout(DEFAULT_TIMEOUT)
     .setConnectionRequestTimeout(DEFAULT_TIMEOUT)
     .setSocketTimeout(DEFAULT_TIMEOUT)
     .build();
    

    CloseableHttpClient httpClient = HttpClients.custom() .setDefaultRequestConfig(requestConfig) .build();

    Spring RestTemplate Connection Timeout is not working

    Java : HttpClient 4.1.2 : ConnectionTimeout, SocketTimeout values set are not effective

提交回复
热议问题