Announcement Announcement Module
No announcement yet.
RestTemplate timeout Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • RestTemplate timeout


    I want to set the connection timeouts for a rest service. I'm using the RestTemplate to talk to my service. I've done some research and I've found and used the xml below (in my application xml) which I believe is meant to set the timeout. I'm using Spring 3.0.

    HTML Code:
    <bean id="RestOperations" class="org.springframework.web.client.RestTemplate">
    			<bean class="org.springframework.http.client.CommonsClientHttpRequestFactory">
    				<property name="readTimeout" value="${restURL.connectionTimeout}" />
    It seems whatever I set the readTimeout to be I get the following:

    Network cable disconnected:
    Waits about 20 seconds and reports following exception:

    org.springframework.web.client.ResourceAccessExcep tion: I/O error: No route to host: connect; nested exception is No route to host: connect

    Url incorrect so 404 returned by rest service:
    Waits about 10 seconds and reports following exception:

    org.springframework.web.client.HttpClientErrorExce ption: 404 Not Found

    My requirements require shorter timeouts so I need to be able to change these. Any ideas as to what I'm doing wrong?

    Many thanks.

  • #2
    Is there no solution for this?


    • #3
      I tried this config too and the behavior is still as described above:

      HTML Code:
       <bean id="RestOperations" class="org.springframework.web.client.RestTemplate">
      		<constructor-arg ref="httpClientFactory"/>
          <bean id="httpClientFactory" class="org.springframework.http.client.CommonsClientHttpRequestFactory">
              <constructor-arg ref="httpClient"/>
      	<bean id="httpClient" class="org.apache.commons.httpclient.HttpClient">
              <constructor-arg ref="httpClientParams"/>
          <bean id="httpClientParams" class="org.apache.commons.httpclient.params.HttpClientParams">
          	<property name="connectionManagerTimeout" value="2000"/>