Reputation: 539
i'm trying to set a timeout on a webservicetemplate and it works only if it is under 21 seconds, if i try to set the timeout over 21 seconds it won't work it will timeout everytime when it reaches 21 seconds.I've tried lots of configs and mostly all of them are doing the same thing.
@Bean
public WebServiceTemplate munisService() {
WebServiceTemplate template = new WebServiceTemplate();
template.setMarshaller(service1Marshaller());
template.setUnmarshaller(service1Marshaller());
template.setDefaultUri(ancomUrl);
HttpComponentsMessageSender httpComponentsMessageSender = new HttpComponentsMessageSender();
httpComponentsMessageSender.setReadTimeout(180000);
httpComponentsMessageSender.setConnectionTimeout(180000);
template.setMessageSender(httpComponentsMessageSender);
return template;
}
@Bean
ServiceImpl ServiceBean(Jaxb2Marshaller marshaller) {
ServiceImpl service= new ServiceImpl ();
service.setWebServiceTemplate(munisService());
service.setDefaultUri(ancomUrl);
service.setMarshaller(marshaller);
service.setUnmarshaller(marshaller);
return service;
}
Does anyone know why is this happening? If it helps this is the exception and i'm using httpclient 4.5.13
org.springframework.ws.client.WebServiceIOException: I/O error: Connection timed out: connect; nested exception is java.net.ConnectException: Connection timed out: connect
Also the request is done on localhost, i'm running a spring boot app on localhost which does some requests.
Upvotes: 4
Views: 2588
Reputation: 19043
Try putting this configuration property in application.yaml
if you use an embedded server with spring boot
server.connection-timeout=120s
It can be that the server itself forces a timeout to the connection after those 21 seconds
Can you try in your code with
httpComponentsMessageSender.setReadTimeout(0);
httpComponentsMessageSender.setConnectionTimeout(0);
According to documentation 0
value means never timeout. Then we maybe retrieve something more from logs as to what causes that timout.
spring documentation for httpComponentsMessageSender
Upvotes: 1