ilovkatie ilovkatie - 4 months ago 34
Java Question

Setting a client receiveTimeout for CXF service above 4 minutes

I have generated an CXF service and set timeouts for

120000ms = 2min
for both:

requestContext.put("javax.xml.ws.client.receiveTimeout", 120000);
requestContext.put("javax.xml.ws.client.connectionTimeout", 120000);


It is working fine, I have tested it for
20s, 1min, 3min
- everytime it is waiting for response exacly that amout of time.

However problem apears when I wanted to set it on
5min
. Service is waiting for resposne only for
~240800ms = ~4min
.

I'm calling jboss esb service. This one lasts max
5min
. CXF service is called from inside of simple
.jar
application from my PC, so there is no other servers/containers between (like tomcat etc).

Any ideas to fix my timeout settings?

Using a
Apache CXF 3.0.1


EDIT

What I realized now that I'm getting 2 diffrent messages depends on my timeout settings:


  • If I set it to
    <=4min
    (via my or @pedrofb method), after that amount of time I'm getting:

    org.apache.cxf.interceptor.Fault: Could not send Message.
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:516)

    Caused by: java.net.SocketTimeoutException: SocketTimeoutException invoking http://esb:8080/MyService/ebws/Category/MyService: Read timed out

  • if I set it to
    >4min
    or
    0
    , I'm getting:

    javax.xml.ws.soap.SOAPFaultException: No response received for service [Category:MyService], Told not to retry.



To be honest, I'm pretty confused what is an expected result (first one, I think)

EDIT 2

I have tested
MyService
via
SoapUI
. I have set a
5min
timeout there and shoot with sample request.

Again, after little more then 4 min I'm getting a:

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<env:Fault>
<faultcode>env:Server</faultcode>
<faultstring>No response received for service [Category:MyService], Told not to retry.</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>


However when I look into log of Jboss ESB I have no exceptions, no errors,
MyService
last a 1 min more (about 5 min) and return normal response - which is confirmed by audit tool (which register every request to my esb - with response and time).

I think that this point on that what @pedrofb mentioned in comment. Any suggestions what this can be?

Answer

Maybe your problem is similar to this http://rayploski.blogspot.com.es/2010/08/jbossesb-setting-up-long-running.html The client receives a timeout while the ESB continue processing. In this case it is needed to configure org.jboss.soa.esb.ws.timeout in ESB

To configure client timeout, seems using requestContext parameters are not standarized see https://java.net/jira/browse/JAX_WS-1166. CXF team suggest they can change

Try using CXF specific parameters for timeout

Client client = ClientProxy.getClient(proxy);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(0);
httpClientPolicy.setReceiveTimeout(0);
http.setClient(httpClientPolicy);

The complete list of parameters is here. 0 means no timeout.