On Mar 27, 2013, at 3:02 PM, Jim Talbut <[email protected]> wrote:

> Hi,
> 
> Is there any way to get TCP KeepAlives (NOT HTTP KeepAlives) enabled for a 
> CXF client?

The normal HTTPConduit that we use is based on the in-JDK HttpURLConnection 
object.   Looking through there (and some googling) and I'm not seeing any way 
at all to control the SO_KEEPALIVE of the underlying socket.   There is no 
access to the Socket at all.    You MAY be able to use some reflection or 
something to get to the private fields of the underlying Oracle implementation 
to set it, but that certainly won't be easy.

You may have better luck with the Apache HTTP Async Client based HTTPConduit:
http://cxf.apache.org/docs/asynchronous-client-http-transport.html
there are settings already there for setting the SO_KEEPALIVE and such.

> I have a client making a request to a server that is taking a very long time 
> respond, and in that time the firewall in between is closing the connection 
> due to inactivity.

If you have control over the server, you could have it send back periodic HTTP 
100 Continue things to keep some activity on the connection.    That said, if 
it's normal to take that long, it's likely better to split the request into two 
parts:

String doSomethingThatMayTakeAWhile(…params);
Result getResult(String…);

Return immediately from the first with some sort of ID or something.   Then on 
the client side, immediately call the second which can block waiting for the 
result.    If the second call times out or connection is dropped, just call it 
again.


-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to