'Read Timeout not working when using resttemplate

I have question regarding resttemplate is not timing out on one of the endpoint. https://api-proxy.pipedrive.com

I have tested following solution using which i am getting timeout error. but when making request to above url sometime it just hangs and not returning response.

1ST:

@Bean def restTemplate(restTemplateBuilder: RestTemplateBuilder): RestTemplate = {
        restTemplateBuilder.setConnectTimeout(5000).setReadTimeout(60000).build()
    }

2ND:

def getClientHttpRequestFactory: ClientHttpRequestFactory = {
        val timeout = 5000
        val config = RequestConfig
          .custom
          .setConnectTimeout(timeout)
          .setConnectionRequestTimeout(timeout)
          .setSocketTimeout(60 * 1000) // 1 minute read-timeout
          .build

        val client = HttpClientBuilder
          .create
          .setDefaultRequestConfig(config)
          .build

        new HttpComponentsClientHttpRequestFactory(client)
    }

    @Bean def restTemplate(restTemplateBuilder: RestTemplateBuilder): RestTemplate = {
        new RestTemplate(getClientHttpRequestFactory)
    }

my code:

def getRequestAuthorizationHeader: LinkedMultiValueMap[String, String] = {
    val httpHeaders = new LinkedMultiValueMap[String, String]
    httpHeaders.add("Authorization", s"Bearer $accessToken")
    httpHeaders
  }
val entity = new HttpEntity[String](getRequestAuthorizationHeader)
val response = restTemplate.exchange(s"https://api-proxy.pipedrive.com/deals", HttpMethod.GET, entity, classOf[String])

Is any way that i could debug or find a root cause for this ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source