Results 1 to 3 of 3

Thread: RestTemplate timeout

  1. #1
    Join Date
    Oct 2012
    Posts
    4

    Default RestTemplate timeout

    Hi,

    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">
    		<constructor-arg>
    		
    			<bean class="org.springframework.http.client.CommonsClientHttpRequestFactory">
    				<property name="readTimeout" value="${restURL.connectionTimeout}" />
    			</bean>
    		</constructor-arg>
    	</bean>
    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 java.net.NoRouteToHostException: 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. #2
    Join Date
    Oct 2012
    Posts
    4

    Default

    Is there no solution for this?

  3. #3
    Join Date
    Oct 2012
    Posts
    4

    Default

    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>
    
        <bean id="httpClientFactory" class="org.springframework.http.client.CommonsClientHttpRequestFactory">
            <constructor-arg ref="httpClient"/>
        </bean>
    	
    	<bean id="httpClient" class="org.apache.commons.httpclient.HttpClient">
            <constructor-arg ref="httpClientParams"/>
        </bean>
        
        <bean id="httpClientParams" class="org.apache.commons.httpclient.params.HttpClientParams">
        	<property name="connectionManagerTimeout" value="2000"/>
        	
    	</bean>
        

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •