I am using a spring STS to develop the project which has the embedded tc server. I don't know what causes this issue, but my rest service always gets timeout of 60 seconds, even though I tried to keep timeout=100 in @Transactional and I tried putting the value in jpa.xml file too. Can anybody tell me how to increase the timeout?
Asked
Active
Viewed 1,358 times
1
-
Are you saying you need to increase the server time out for STS which has embeded tomcat server? – Pradeep Jul 06 '17 at 07:56
-
ha, yes pradeep – dhari m Jul 06 '17 at 08:26
-
Service timeout? It must be a `read time out` on the client, then? Or does your `JPA` query time out at 60 seconds but you are still expecting your client to wait for the result? – Zilvinas Jul 06 '17 at 08:48
-
yes Zilvinas , JPA query timed out at 60 seconds even thought I have nowhere mentioned it – dhari m Jul 06 '17 at 08:52
-
Hello Dhari,Hope my answer helped you .If yes please accept the answer if not please let me know so that I can improvise on that help you to give a better solution. – Pradeep Aug 10 '17 at 13:52
2 Answers
2
if you are using RestTemplate than you should use following code to implement timeouts
@Bean
public RestTemplate restTemplate() {
return new RestTemplate(clientHttpRequestFactory());
}
private ClientHttpRequestFactory clientHttpRequestFactory() {
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
factory.setReadTimeout(2000);
factory.setConnectTimeout(2000);
return factory;
}}
The x
ml configuration
<bean class="org.springframework.web.client.RestTemplate">
<constructor-arg>
<bean class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory"
p:readTimeout="2000"
p:connectTimeout="2000" />
</constructor-arg>

Pradeep
- 1,947
- 3
- 22
- 45
1
Hello Dhari,
Please double click on the embedded tomcat server .You can modify the time out seconds as per your wish. Please look at the screen shot provided.
More over your question is not related to increase the service timeout instead it should be server timeout which was pretty fishy to understand.Kindly update your question as suggested.

Pradeep
- 1,947
- 3
- 22
- 45
-
Thanks for your answer pradeep. I thought there may be any relation bw server timeout and rest service timeout, but not. Now My problem is whenever I called my rest service it's always timed out at 60 seconds even thought I kept timeout=100 at the top of the class, can U tell me what to do – dhari m Jul 06 '17 at 08:47