Tuesday, November 22, 2011

Overcoming : "AxisFault: Timeout waiting for connection" issue

This issue[1] you might face when you run your axis2client code in a loop  against a service..

To overcome above issue, set the "MULTITHREAD_HTTP_CONNECTION_MANAGER" property in the axis2 ConfigurationContext.

ConfigurationContext configContext =   ConfigurationContextFactory.  createConfigurationContextFromFileSystem("CARBON_HOME\\repository\\deployment\\client", "CARBON_HOME\\repository\\conf\\axis2_client.xml");

MultiThreadedHttpConnectionManager httpConnectionManager =  new MultiThreadedHttpConnectionManager();       

configContext.setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER,  httpConnectionManager);

[1]
Caused by: org.apache.axis2.AxisFault: Timeout waiting for connection
       at org.apache.axis2.AxisFault.
makeFault(AxisFault.java:430)
       at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:197)
       at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
Caused by: org.apache.commons.httpclient.
ConnectionPoolTimeoutException:
Timeout waiting for connection
       at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.doGetConnection(MultiThreadedHttpConnectionManager.java:490)
       at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager.getConnectionWithTimeout(MultiThreadedHttpConnectionManager.java:394)

3 comments:

  1. can also be done this way:

    MultiThreadedHttpConnectionManager manager = new MultiThreadedHttpConnectionManager();
    manager.getParams().setDefaultMaxConnectionsPerHost(threads);
    HttpClient client = new HttpClient(manager);
    stub._getServiceClient().getServiceContext().getConfigurationContext().setProperty(HTTPConstants.CACHED_HTTP_CLIENT, client);

    Thanks

    ReplyDelete