2017-07-10 1 views
1

私はHtmlUnitとSpringを使用します。私はXMLでPOSTメソッドを受け付けるWebサービスを持っています。任意の機会にうまくいきましたが、サーバに通信できません。メッセージでIOExceptionをスローします。ターゲットサーバが応答しませんでした。リトライ回数を設定するにはSpringのHtmlUnitリクエスト?

19:32:01.489 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 5][route: {}->http://][total kept alive: 0; route allocated: 0 of 6; total allocated: 0 of 20] 
19:32:01.489 [main] INFO org.apache.http.impl.execchain.RetryExec - I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {}->http:// The target server failed to respond 
19:32:01.489 [main] DEBUG org.apache.http.impl.execchain.RetryExec - The target server failed to respond 
org.apache.http.NoHttpResponseException: The target server failed to respond 


    WebClient webClient = new WebClient(BrowserVersion.FIREFOX_52); 
    webClient.getOptions().setTimeout(20000); 
    webClient.getOptions().setThrowExceptionOnScriptError(false); 
    webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); 
    webClient.getOptions().setCssEnabled(false); 
    webClient.getOptions().setJavaScriptEnabled(true); 
    webClient.getOptions().setUseInsecureSSL(true); 
    webClient.getOptions().setRedirectEnabled(true); 
    webClient.waitForBackgroundJavaScriptStartingBefore(20000); 

ランダムリクエストは受け入れられますが、一部は拒否されることがあります。この状況は、私は春のブートを使用していた!コンテナは応答を多くの(3)回処理しないためです。私が春にテストを実行すると、3回の試行でリクエストが実行されます。 リトライ回数を設定できますか?
この問題を回避して一度にリクエストを実行するにはどうすればよいですか?

答えて

0

おそらく、HttpClientのバグです。

HttpClient 4.4を使用している場合は、4.4.1にアップグレードしてください。

詳細については、this linkをご覧ください。

アップグレードできない場合は、次のリンクを参考にしてください。

http://www.nuxeo.com/blog/using-httpclient-properly-avoid-closewait-tcp-connections/

+0

ありがとうございました。私はHtmlUnitを使用する場合、4.4.1にHttpClient 4.4をアップグレードする方法を理解できませんか? – makson

関連する問題