デプロイした CXF Web サービスのメソッドを WS クライアントから呼び出そうとすると、接続がタイムアウトになります。どちらもカスタム インターセプターを使用しており、複数の呼び出しによりサービスが過負荷になっています。
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/test/resources/cxf.xml をロードしました。
残念ながら、接続タイムアウトは引き続き発生します。
私が試した 2 番目の解決策は、次のコードを使用して、すべてのクライアントにプログラムでポリシーを設定することです。
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);
}
しかし、再び接続タイムアウトが発生します。
私は何かが恋しいですか?他に設定するタイムアウトはありますか? どんな助けでも大歓迎です。