You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@directory.apache.org by za...@email.cz on 2014/10/13 21:45:36 UTC
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, ..?). Are there any examples or documentation I
could read to understand how to use the pool?
Any help appreciated,
Thanks
Martin
Re: Ldap persistent connection pool issues
Posted by Emmanuel Lécharny <el...@gmail.com>.
Hi,
Le 13/10/14 21:45, zapletal-martin@email.cz a écrit :
> 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, ..?). Are there any examples or documentation I
> could read to understand how to use the pool?
It's likely that your system is dropping the socket connection when it's
not used for a long time.
We can have a look and make it more solid by testing the connection
before you can use it, but this is a costly operation (it, it wll
require a round trip to the server before any request is done).
I would suggest you create a JIRA with the description of your problem
which is likely to hit other users.
Thanks !