Web-Service on Tomcat with Timeout

[亡魂溺海] 提交于 2019-12-13 03:47:29

问题


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(...);


来源:https://stackoverflow.com/questions/4472210/web-service-on-tomcat-with-timeout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!