0
当我尝试从WS客户端调用已部署的CXF Web服务的方法时,我得到连接超时。两者都使用自定义拦截器,并且由于多次调用而导致服务超负荷。CXF java.net.ConnectException:连接超时
Caused by: java.net.ConnectException: ConnectException invoking http://xxx.xx.xx.xx:12005/myservice/repository?wsdl: Connection timed out
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1338)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1322)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:622)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
... 36 more
我尝试了多种解决方案来禁用超时或增加它,但都失败。
首先,我试图创建如下所示的CXF配置文件:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
xsi:schemaLocation="http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<http-conf:conduit name="*.http-conduit">
<http-conf:client CacheControl="no-cache"
ConnectionTimeout="0" ReceiveTimeout="0" AllowChunking="false" />
</http-conf:conduit>
</beans>
然后,我强迫我的应用程序通过使用Java系统属性-Dcxf.config.file=/home/test/resources/cxf.xml
在日志中我可以加载它该配置是只读看到,因此可能应用于
信息:加载配置文件/ home /测试/资源/ cxf.xml。
不幸的是,连接超时仍然发生。
我尝试第二种解决方案包括通过下面这段代码编程设置所有客户端上的策略:
public static void setHTTPPolicy(Client client) {
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(0);
httpClientPolicy.setReceiveTimeout(0);
httpClientPolicy.setAsyncExecuteTimeout(0);
http.setClient(httpClientPolicy);
}
但再次连接超时。
我想念什么?是否有其他超时配置?任何帮助是受欢迎的。
连接超时通常是另一个问题的症状,而不是由本身的原因。你是说对于服务的一些调用,连接*不*超时? – kolossus
是的,有些调用运行良好。我的场景包括传输大附件,因此它解释了超时。我遇到的问题实际上是在客户端和服务器端配置超时。 – Laurent
啊。然后我会推荐线程池。很快找到我的答案。 – kolossus