简体   繁体   English

Tomcat 上的 Web 服务超时

[英]Web-Service on Tomcat with Timeout

I have an application witch runs about 30 min.我有一个应用程序运行大约 30 分钟。 with some input data.一些输入数据。 It has also test data, so the application takes about 30 sec.它还具有测试数据,因此应用程序大约需要 30 秒。

The application should be available in a webservice.该应用程序应该在网络服务中可用。 I used CXF and tomcat.我使用了 CXF 和 tomcat。 All works fine with the testdata.使用测试数据一切正常。 With real data there is a timeout after about 1 min: a SocketTimeoutException对于真实数据,大约 1 分钟后会出现超时:SocketTimeoutException

I had a look at all timeout parameters (server.xml, all web.xml) but doesn't help.我查看了所有超时参数(server.xml,所有 web.xml),但没有帮助。

My application is very memory consuming.我的应用程序非常消耗内存。 I added this vm value to the server -Xmx1600m.我将此 vm 值添加到服务器 -Xmx1600m。 Without, I get a OutOfMemoryException没有,我得到一个 OutOfMemoryException

Any idea what I could still try?知道我还能尝试什么吗? Can I set the memory on level session?我可以在关卡会话中设置内存吗? Thanks!谢谢!

Disclaimer: I've never worked with CXF 免责声明:我从未与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. 给出的示例代码表明使用带有HTTPConduitHTTPCLientPolicy可以解决问题。

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

You problem is outOfMemory, Can you try to change the parameter -Xmx1600m for -Xmx2048m or more.您的问题是 outOfMemory,您能否尝试将参数 -Xmx1600m 更改为 -Xmx2048m 或更多。 It into file /etc/init.d/tomcat它进入文件/etc/init.d/tomcat

### BEGIN INIT INFO
# Provides: tomcat8
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start:
# Default-Stop:
# Description: Tomcat 8
# Short-Description: start and stop tomcat
### END INIT INFO

## Source function library.
#. /etc/rc.d/init.d/functions
#export JAVA_HOME=/usr/java/default
export JAVA_HOME=/opt/jdk1.8.0_201
export JAVA_OPTS="-Dfile.encoding=UTF-8 \
  -Dnet.sf.ehcache.skipUpdateCheck=true \
  -XX:+UseConcMarkSweepGC \
  -XX:+CMSClassUnloadingEnabled \
  -XX:+UseParNewGC \
  -XX:MaxPermSize=256m \
  -Xms512m -Xmx2048m"
export PATH=$JAVA_HOME/bin:$PATH
TOMCAT_HOME=/opt/tomcat-latest
TOMCAT_USER=root
SHUTDOWN_WAIT=20

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM