javaweb-servicescxfcxf-client

Cxf client takes too long time when response comes late


I am using cxf library for a web service client.

When the response comes late around 5 seconds, the cxf takes around 20 seconds to return the response. The ws returns a 33912 long response.

The client has no problem with the fast responses though.

I can't find what the problem is. I tested the ws endpoint and it returns max in 8 seconds. But the cxf client sometimes takes 30-50 seconds.

I opened the debug logs, and between these two lines it takes 9 seconds

2018-01-11 17:17:14.022 DEBUG 10492 --- [nio-8086-exec-6] o.apache.cxf.transport.http.HTTPConduit : Sending POST Message with Headers to http://example.com/service Conduit :{http://example.com./}ExampleWebServicePort.http-conduit

2018-01-11 17:17:23.370 DEBUG 10492 --- [nio-8086-exec-6] org.apache.cxf.endpoint.ClientImpl : Interceptors contributed by bus: [org.apache.cxf.ws.policy.PolicyInInterceptor@3ec595ab]

This is the client:

HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
            httpConduit.setAuthSupplier(null);
            httpConduit.setAuthorization(null);
            HTTPClientPolicy clientPolicy = new HTTPClientPolicy();
            clientPolicy.setConnectionTimeout(60000L);
            clientPolicy.setReceiveTimeout(60000L);
            httpConduit.setClient(clientPolicy);

What might cause this problem?


Solution

  • The problem was that i thought the server was responding fast but i was testing with the wrong endpoint.
    When i tested correct endpoint i realized that the server was indeed responding late.
    The response time of the client matched the response times of the server.