Please take a look at the api docs on how to bind and unbind the connection..
I can later provide some example On Wednesday, October 15, 2014, <[email protected]> wrote: > Hello, > > > > we are still having issues with the below. > > > > > Any help on how to properly handle connection pool, what exceptions to look > for and how to react to their occurence etc. to guarantee long life of the > connection would be very appreciated. > > > > > Thank you > > > > ---------- Původní zpráva ---------- > Od: [email protected] <javascript:;> > Komu: [email protected] <javascript:;> > Datum: 13. 10. 2014 15:45:36 > Předmět: Ldap persistent connection pool issues > > " > Hello, > > > > we are building a service using Apache Directory LDAP API. It should be a > long running service so it should manage the LDAP connection properly to > avoid disconnects or other issues after being up for a long time. > > > > > The code we are using looks roughly like this > > > > > Initialization: > > > > > > LdapConnectionConfig config = new LdapConnectionConfig() > > config.setLdapHost(...) > > config.setLdapPort(...) > > config.setName(...) > > config.setCredentials(...) > > > > > connectionPool = new LdapConnectionPool(new > PoolableLdapConnectionFactory(config)) > > connectionPool.setTestOnBorrow(true) > > connectionPool.setTestOnReturn(true) > > > > > > On each request > > > > > > LdapConnection connection = connectionPool.getConnection() > > connection.setTimeOut(...) > > ... //Do search/add/delete/modify using the connection > > connectionPool.releaseConnection(connection) > > > > > > We are currently trying to troubleshoot the service. Everything works fine, > but after some time the service logs error similar to the below and stops > working. Restart of the service fixes the issue. Therefore we suspect the > long running nature of the service and we believe we may be using the > connection pool incorrectly (e.g. not releasing the connection correctly) > > > > > > ERROR[ForkJoinPool-2-worker-3] PoolableLdapConnectionFactory - unable to > unbind connection: Cannot connect on the server, the connection is invalid > > > > > Unfortunately it is difficult to find documentation or examples of proper > usage of connection pool. Are we using it right or are we missing some > steps > (e.g. bind, unbind, connect, reconnect after some time, ..?). Are there any > examples or documentation I could read to understand how to use the pool? > > > > > Any help appreciated, > > > > > Thanks > > Martin > > > " >
