CXF's AsyncHTTPConduitFactory.CONNECTION_TTL has no effect
Issue
-
We are developing a SOAP client based on JBoss Fuse 6.2.1. The implementation uses CXF client API in Asynchronous mode (async HTTP client).
Our requirements are that the connections, once established, should only be closed after 60 seconds of idle time.
Additionally, a SOAP request that not receive its SOAP response must timeout after 5 seconds. -
The 5 seconds timeout works properly.
However we noticed that when a response is received within the 5 seconds, the connection is still disconnected after 5 seconds instead of the configured 60 seconds of idle time.
Test was performed with JBoss Fuse 6.2.1 running on Windows with an Oracle 8u60 JVM. -
We digged into the issue and we have observed that the CXF Client uses wrongly the
receiveTimeout
value for both theconnectionTimeout
as well as for therequestTimeout
.
The Bus is configured to always use the Async API, with a connection TTL of 60 seconds :
Bus bus = BusFactory.getDefaultBus();
bus.setProperty(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE);
bus.setProperty(AsyncHTTPConduitFactory.USE_POLICY, UseAsyncPolicy.ALWAYS);
bus.setProperty(AsyncHTTPConduitFactory.CONNECTION_TTL, 60000L);
The HTTPConduit is configured to use a policy with a receiveTimeout of 5 seconds:
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setReceiveTimeout(5000L);
conduit.setClient(policy);
-
Upon execution, the WireShark network traffic capture shows that even though the connection TTL was set at 60 seconds, the connection is closed after 5 seconds.
While debugging the code, we have observed that the value ofHTTPClientPolicy.getReceiveTimeout()
is used twice:- once for configuring the socketTimeout in the
AsyncHTTPConduit.setupConnection()
. - once for configuring the requestTimeout in the
AsyncWrappedOutputStream.getHttpResponse()
.
- once for configuring the socketTimeout in the
-
The solution would be to set the
socketTimeout
to the value of theCONNECTION_TTL
configured on the Bus, instead of reusing the value of receiveTimeout.
Environment
- Red Hat JBoss Fuse
- 6.2.1
- Apache CXF
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.