axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christian H. (JIRA)" <j...@apache.org>
Subject [jira] [Created] (AXIS2-5809) Axis2 does not properly return http connection to connection pool when using http client 4
Date Tue, 27 Sep 2016 06:40:21 GMT
Christian H. created AXIS2-5809:
-----------------------------------

             Summary: Axis2 does not properly return http connection to connection pool when
using http client 4
                 Key: AXIS2-5809
                 URL: https://issues.apache.org/jira/browse/AXIS2-5809
             Project: Axis2
          Issue Type: Bug
          Components: transports
    Affects Versions: 1.7.3
         Environment: Ubuntu 16.04, OpenJDK 7
            Reporter: Christian H.
            Priority: Critical


When using HTTP Client 4 with a generated WSDL-Client the HTTP connections are not returned
properly to underlying connection pool. The HTTP connections are still allocated, when new
requests are made. This ends up in waiting for HTTP connections from pool, but no connections
are available anymore.

The connections should be returned to pool as stated in the Apache HTTP Client 4 documentation
(2.3.1):
https://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html

Here is some example code to reproduce the problem. The BLZServiceStub is a generated WSDL
client (wsdl2java) of the following service: http://www.thomas-bayer.com/axis2/services/BLZService?wsdl
. But the problem is independent of the used service.


{code:title=TestRunner.java}
package com.thomas_bayer.blz;

import java.rmi.RemoteException;

import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.params.HttpParams;

public class TestRunner {

  private static final int timeoutMillis = 5000;
  private static final int maxConnections = 2;
  
  private static final String[] BLZs = new String[] {
      "12030000", "12070000"
  };
  
  public static void main(String[] args) throws RemoteException {
    BLZServiceStub blzService = new BLZServiceStub();
    blzService._getServiceClient().getServiceContext().getConfigurationContext().setProperty(HTTPConstants.CACHED_HTTP_CLIENT,
buildHttpClient());

    for(int i = 0; i <= maxConnections; i++) {
      BLZServiceStub.GetBankType getBankType = new BLZServiceStub.GetBankType();
      getBankType.setBlz(BLZs[i % BLZs.length]);
      BLZServiceStub.GetBank getBank = new BLZServiceStub.GetBank();
      getBank.setGetBank(getBankType);
      
      System.out.println("Querying for bank (iteration: " + i + ")");
      BLZServiceStub.GetBankResponse response = blzService.getBank(getBank);
      System.out.println("Bank queried");
      
      System.out.println("Result: " + response.getGetBankResponse().getDetails().getBezeichnung());
    }
  }

  protected static HttpClient buildHttpClient() {
    final PoolingClientConnectionManager conmgr = new PoolingClientConnectionManager();
    conmgr.setDefaultMaxPerRoute(maxConnections);
    conmgr.setMaxTotal(maxConnections);
    
    final HttpParams params = new BasicHttpParams();
    params.setLongParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeoutMillis);
    params.setLongParameter(CoreConnectionPNames.SO_TIMEOUT, timeoutMillis);
    
    return new DefaultHttpClient(conmgr, params);
  }
}
{code}

Running this code will produce the following output:

{noformat}
Querying for bank (iteration: 0)
Bank queried
Result: Deutsche Kreditbank Berlin
Querying for bank (iteration: 1)
Bank queried
Result: Deutsche Bank Ld Brandenburg
Querying for bank (iteration: 2)
Sep 27, 2016 8:32:43 AM org.apache.axis2.transport.http.impl.httpclient4.HTTPSenderImpl sendViaPost
INFORMATION: Unable to sendViaPost to url[http://www.thomas-bayer.com/axis2/services/BLZService]
org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool
	at org.apache.http.impl.conn.PoolingClientConnectionManager.leaseConnection(PoolingClientConnectionManager.java:232)
	at org.apache.http.impl.conn.PoolingClientConnectionManager$1.getConnection(PoolingClientConnectionManager.java:199)
	at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:456)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
	at org.apache.axis2.transport.http.impl.httpclient4.HTTPSenderImpl.executeMethod(HTTPSenderImpl.java:873)
	at org.apache.axis2.transport.http.impl.httpclient4.HTTPSenderImpl.sendViaPost(HTTPSenderImpl.java:238)
	at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:121)
	at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:403)
	at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:234)
	at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:431)
	at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:399)
	at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
	at org.apache.axis2.client.OperationClient.execute(OperationClient.java:150)
	at com.thomas_bayer.blz.BLZServiceStub.getBank(BLZServiceStub.java:162)
	at com.thomas_bayer.blz.TestRunner.main(TestRunner.java:34)

Exception in thread "main" org.apache.axis2.AxisFault: Timeout waiting for connection from
pool
	at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
	at org.apache.axis2.transport.http.impl.httpclient4.HTTPSenderImpl.sendViaPost(HTTPSenderImpl.java:242)
	at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:121)
	at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:403)
	at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:234)
	at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:431)
	at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:399)
	at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
	at org.apache.axis2.client.OperationClient.execute(OperationClient.java:150)
	at com.thomas_bayer.blz.BLZServiceStub.getBank(BLZServiceStub.java:162)
	at com.thomas_bayer.blz.TestRunner.main(TestRunner.java:34)
Caused by: org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection
from pool
	at org.apache.http.impl.conn.PoolingClientConnectionManager.leaseConnection(PoolingClientConnectionManager.java:232)
	at org.apache.http.impl.conn.PoolingClientConnectionManager$1.getConnection(PoolingClientConnectionManager.java:199)
	at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:456)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
	at org.apache.axis2.transport.http.impl.httpclient4.HTTPSenderImpl.executeMethod(HTTPSenderImpl.java:873)
	at org.apache.axis2.transport.http.impl.httpclient4.HTTPSenderImpl.sendViaPost(HTTPSenderImpl.java:238)
	... 9 more
{noformat}


The exception is thrown after some timeout waiting for the connection manager to return a
connection.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


Mime
View raw message