You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by FlorianK <fl...@yahoo.com> on 2016/02/25 21:53:47 UTC

How to set custom KeepAliveStrategy in AsyncHTTPConduitFactory

Hi,

I realize that the subject of my email is very specific, the specifics as to
why I am asking for this can be found below (its long). But in a nutshell we
need a way to specify our own implementation of  ConnectionKeepAliveStrategy
<https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/ConnectionKeepAliveStrategy.html>  
when using Asynchronous Client HTTP Transport. Short of implementing our own
Custom transport for HTTP so we can extend AsyncHTTPConduitFactory and
override createClient and call DefaultHttpAsyncClient#setKeepAliveStrategy
on the client, we are stuck. Is there a mechanism to get hold of the
HttpAsyncClient to set the strategy or could a new property like 
org.apache.cxf.transport.http.async.keepAliveStrategyClass 
be supported?

Context:

We are using CXF 3.1.4 in production and we have been experiencing problems
with invocations of web services that support HTTP keep alive. Every now and
then we would get this exception:

java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:792)
~[na:1.8.0_40]

We established that this happens when a rare racing condition occurs where
the Jdk HttpURLConnection keep alive pool picks up a connection whose TTL is
just about to expire. The client then makes the request and waits for the
HTTP header in the response. If the network latency is on the longer side it
can happen that the server has closed the connection which it sees as idle.
The client therefore never gets the header response and we get the exception
above. We overcame the problem by simply making the idle timeout on the
client shorter than on the server by one second. Since there is no easy way
to change how keep alive connections are handled by the JDK we switched to
using the Apache Http client, which means switching to asynch in CXF.
Unfortunately the CXF classes that create the async http client do not
expose all the properties that client class has such as the
KeepAliveStrategy. Hence our request to expose that property.

Thank you in advance for help with this matter.

Florian






--
View this message in context: http://cxf.547215.n5.nabble.com/How-to-set-custom-KeepAliveStrategy-in-AsyncHTTPConduitFactory-tp5766314.html
Sent from the cxf-user mailing list archive at Nabble.com.