Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3630

Spring RestTemplate timeout

$
0
0

I would like to set the connection timeouts for a rest service used by my web application. I'm using Spring's 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.

I've also seen the same problem here Timeout configuration for spring webservices with RestTemplate but the solutions don't seem that clean, I'd prefer to set the timeout values via Spring config

<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.ResourceAccessException: 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.HttpClientErrorException: 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.


Viewing all articles
Browse latest Browse all 3630

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>