Web-Service on Tomcat with Timeout

2019-08-25 00:57发布

问题:

I have an application witch runs about 30 min. with some input data. It has also test data, so the application takes about 30 sec.

The application should be available in a webservice. I used CXF and tomcat. All works fine with the testdata. With real data there is a timeout after about 1 min: a SocketTimeoutException

I had a look at all timeout parameters (server.xml, all web.xml) but doesn't help.

My application is very memory consuming. I added this vm value to the server -Xmx1600m. Without, I get a OutOfMemoryException

Any idea what I could still try? Can I set the memory on level session? Thanks!

回答1:

Disclaimer: I've never worked with CXF

This blog here seens to be describing a very similar situation to your timeout.

The sample code given their indicates the use of an HTTPConduit with an HTTPCLientPolicy can solve the issue.

MyWebService service = new MyWebService();
MyWebServicePortType client = service.MyWebServicePort();

Client cl = ClientProxy.getClient(client);

HTTPConduit http = (HTTPConduit) cl.getConduit();

HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(0);
httpClientPolicy.setReceiveTimeout(0);

http.setClient(httpClientPolicy);

client.doSomething(...);