Wildfly 8.2 /读取时间超时

时间:2015-03-27 15:04:10

标签: java-8 wildfly wildfly-8 saaj undertow

我最近使用java1.8将我的项目从jboss4迁移到了wildfly 8.2。我有一个使用SAAJ的webservice调用,它在命令行中运行良好。但是当它从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)

我读了here我可以设置超时但我不必因为程序运行正常而没有从命令行超时因此它不是saaj超时问题。我非常确定wildfly / underow是因为某种原因读出套接字的时间。

感谢任何帮助。

---更多细节---

目前我正在使用wildfly8.2附带的下载1.1 Final。我尝试将升级升级到1.2 beta,结果仍然相同。

调用失败:

        responseMsg = soapConn.call(soapMessage, wsdlLoc);

在wildfly8.2中取消配置:

    <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服务器上调用的。所以基本上,客户端webservice在60秒内从wildlfy调用,但是如果我从独立的Java客户端运行相同的调用,并且相同的代码工作正常。我甚至在jboss community打开了一个帖子,我还没有听到任何

3 个答案:

答案 0 :(得分:2)

我能够通过改变apache-cxf源中的接收超时并为wildfly8.2重建它来解决这个问题

简要说明:(版本必须完全是这些,否则编译失败)。

  1. 从apache下载CXF2.7.15 src
  2. 下载jdk1.6最新版本
  3. 下载3.0.4
  4. 导出JAVA_HOME = path-to-jdk1.6
  5. 将jdk1.6 / bin和maven / bin添加到PATH
  6. 导出MAVEN_OPTS = -Xmx512m以修复permgen错误
  7. 打开./rt/transports/http/src/main/resources/schemas/wsdl/http-conf.xsd并将ReceiveTimeout从60000更改为例如所需的任何内容。 600000(10分钟)
  8. 运行mvn -Pfastinstall
  9. 具有HTTPConduit套接字超时的文件是HTTPClientPolicy.java,它位于./rt/transports/http/target/cxf-rt-transports-http-2.7.15.jar中。将此jar复制到apache / cxf / impl / main文件夹下的wildfly8.2模块中。另外,编辑module.xml以使用此jar。

    我还必须将standalone.xml中的读取超时设置更改为更高的值,以阻止它重新尝试请求。

    希望这有帮助。

答案 1 :(得分:0)

或者,此问题已在wildfly 9中得到解决。开发人员可以通过设置系统属性来覆盖默认的CXF HTTP管道值。有关详细信息,请访问https://docs.jboss.org/author/display/WFLY9/Apache+CXF+integration#ApacheCXFintegration-ApacheCXFinterceptors

答案 2 :(得分:-1)

足以将以下代码添加到您的Web服务使用者:

//import javax.xml.ws.BindingProvider;

//Set timeout until a connection is established
((BindingProvider)this.myService).getRequestContext().put("javax.xml.ws.client.connectionTimeout", "60000"); //one minute

//Set timeout until the response is received
        ((BindingProvider)this.myService).getRequestContext().put("javax.xml.ws.client.receiveTimeout", "600000"); //ten minutes