获取java.net.SocketTimeoutException:连接超时错误

时间:2017-02-14 10:57:08

标签: java apache axis

我正在尝试从我的应用程序连接到Web服务,并且我遇到以下异常:

org.apache.axis2.AxisFault: The host did not accept the connection within timeout of 30000 ms
                at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
                at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:197)
                at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
                at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:404)
                at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231)
                at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
                at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
                at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
                at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)

Caused by: org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept the connection within timeout of 30000 ms
                at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:155)
                at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:130)
                at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
                at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
                at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
                at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
                at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
                at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:621)
                at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)
                ... 27 more
Caused by: java.net.SocketTimeoutException: connect timed out
                at java.net.PlainSocketImpl.socketConnect(Native Method)
                at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
                at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
                at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
                at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:367)
                at java.net.Socket.connect(Socket.java:524)
                at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:545)
                at sun.reflect.GeneratedMethodAccessor197.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:592)
                at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:140)
                ... 35 more

我没有覆盖我的应用程序中的超时间隔。 任何人都可以告诉我这个超时配置的属性是什么?它配置在哪个地方?我认为它在axis2.xml中配置但是我可能错了

1 个答案:

答案 0 :(得分:1)

我不确定你对它的承诺,但默认超时30秒是在axis2的源代码中设置的。

准确地在第118行(axis2版本1.7.4)的 org.apache.axis2.client.Options 中:

public static final int DEFAULT_TIMEOUT_MILLISECONDS = 30 * 1000;

如果未手动设置timout并且其默认值为-1(例如504行),则将使用此默认值。

    return timeOutInMilliSeconds == -1 ? DEFAULT_TIMEOUT_MILLISECONDS
            : timeOutInMilliSeconds;

如果您想覆盖超时,我会引荐您转到axis documentation