我最近使用 java1.8 将我的项目从 jboss4 迁移到 wildfly 8.2。我有一个使用 SAAJ 的 Web 服务调用,它在命令行中运行良好。但是当它从 wildfly8.2 中运行时,它会在 60 秒后超时。我从 jboss 论坛中读到读取请求的默认超时时间为 60 秒。所以我将standalone.xml中的配置更改为
<ajp-listener name="ajp" socket-binding="ajp" max-parameters="10000"/>
**<http-listener name="default" socket-binding="http" max-parameters="10000" read-timeout="120000"/>**
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
但它仍然会在 60 秒后超时,并出现以下错误。
Caused by: java.net.SocketTimeoutException: SocketTimeoutException invoking http://test-server/test/v2.0.0/TestService?wsdl: Read timed out
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.8.0_25]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [rt.jar:1.8.0_25]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.8.0_25]
at java.lang.reflect.Constructor.newInstance(Constructor.java:408) [rt.jar:1.8.0_25]
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1347)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1331)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:632)
at org.jboss.wsf.stack.cxf.saaj.SOAPConnectionImpl.call(SOAPConnectionImpl.java:120)
... 38 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method) [rt.jar:1.8.0_25]
at java.net.SocketInputStream.read(SocketInputStream.java:150) [rt.jar:1.8.0_25]
at java.net.SocketInputStream.read(SocketInputStream.java:121) [rt.jar:1.8.0_25]
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) [rt.jar:1.8.0_25]
at java.io.BufferedInputStream.read1(BufferedInputStream.java:286) [rt.jar:1.8.0_25]
at java.io.BufferedInputStream.read(BufferedInputStream.java:345) [rt.jar:1.8.0_25]
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:703) [rt.jar:1.8.0_25]
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647) [rt.jar:1.8.0_25]
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1534) [rt.jar:1.8.0_25]
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439) [rt.jar:1.8.0_25]
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480) [rt.jar:1.8.0_25]
at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.getResponseCode(URLConnectionHTTPConduit.java:266)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1545)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1515)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1318)
我在这里读到我可以设置超时,但我不必这样做,因为程序运行良好而不会从命令行超时,所以它不是 saaj 超时问题。我很确定 wildfly/undertow 出于某种原因正在计时读取套接字的时间。
任何帮助表示赞赏。
- -更多细节 - -
目前我正在使用wildfly8.2附带的undertow 1.1 Final。我尝试将 undertow 升级到 1.2 beta,结果仍然相同。
调用失败:
responseMsg = soapConn.call(soapMessage, wsdlLoc);
wildfly8.2 中的 Undertow 配置:
<subsystem xmlns="urn:jboss:domain:undertow:1.2">
<buffer-cache name="default"/>
<server name="default-server">
<ajp-listener name="ajp" socket-binding="ajp" max-parameters="10000"/>
<http-listener name="default" socket-binding="http" max-parameters="10000" read-timeout="120000"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="WildFly/8"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
</filters>
</subsystem>
更多细节:
我在 wildfly9.0BETA2 下尝试过,结果相同。如果有帮助,只想分享更多细节。SAAJ webservice 调用是从在 wildfly8.2 中运行的 servlet 进行的,目标 WSDL 在另一个 jboss 服务器上。所以基本上,来自 wildlfy 的客户端 Web 服务调用会在 60 秒内超时,但是如果我从独立的 Java 客户端运行相同的调用并且相同的代码可以正常工作。我什至在jboss 社区上开了一个帖子,但还没有听到任何消息