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