I am using CXF 3.1.10 version to create / consume the REST APIs and noticing an issue with the SSL Keep Alive connections. I've tried using the Async implementation and ran into few issues which I've shared in another post. When we are using the CXF Client libraries for some reason JDK's HTTP URL openConnection is creating a new connection object for every request. I am seeing server is responding with Keep Alive and the corresponding time out configurations. Is there any configuration / setup that I am missing to keep the connections in the JDK default implementation?
I also just created a sample test scenario by making use of Javax.net package and I do see JDK is honoring the Keep Alive connections. I am not really sure if there is something am missing from the CXF libraries.
I have also enabled the http-conduits Keep-Alive connection in my configuration file and loading the pfx certs through the System properties.
> I also just created a sample test scenario by making use of Javax.net
> package and I do see JDK is honoring the Keep Alive connections. I am not
> really sure if there is something am missing from the CXF libraries.
For the client config Keep-Alive is active by default and the connection factory is cached in org.apache.cxf.transport.https.HttpsURLConnectionFactory so this should be fine.
Which kind of server are you using?
I would enable logging on the client side to debug http traffic (or use tools like Wireshark) to see what's going on with the connections.
Tomcat Server Dennis. I did configure the KeepAliveTimeout configurations in the server connector, keepAlive system properties for JRE. It did not work. Tried with a simple webclient call and noticed, CXF is creating new connections for every request and below is the code snippet -
Can someone please provide some inputs on this issue? Any configurations that I'm missing here to tell CXF wrappers to make use of the keep alive connections. Same code is working when I integrate with the simple URL HttpConnection JDK API. Appreciate any inputs on this.
> On Jun 28, 2017, at 7:25 PM, mvraju <[hidden email]> wrote:
> Can someone please provide some inputs on this issue? Any configurations that
> I'm missing here to tell CXF wrappers to make use of the keep alive
> connections. Same code is working when I integrate with the simple URL
> HttpConnection JDK API. Appreciate any inputs on this.
Is your test code actually consuming the data from the response or just printing the status code? If you don’t consume the data (and close the stream), the underlying connection cannot be reused. That’s usually the primary reason for this type of behavior.
In the test code I just tried with capturing the response code. But with the actual implementation, I am also consuming the response. One thing I noticed while I am debugging the with the HttpsURLConnectionFactory class it is looking for flags like useHttpsURLConnectionDefaultSslSocketFactory or any sslFactory instance on the tls parameters. After setting the default flag in the HttpConduit tlsClientParameters configuration I can see the TCP connections are getting reused.