Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Java LDAP Connection Pool

69 views
Skip to first unread message

sudip shrestha

unread,
Oct 24, 2005, 9:45:34 AM10/24/05
to
I am using netscape.ldap.util.ConnectionPool and found that after a while tomcat (5.5.7) server would stop responding to any pages/actions that have to deal with ldap functions...can't even do printPool().  I checked all other stuffs regarding the website, any other pages or actions regarding the datbase or other stuffs work just fine, it is just the ldap related pages such as login...which would just seem to get hung up...
If anybody has any experience using this ConnectionPool in production environment, please let me know. Any suggestions would be helpful.

Brandon Keepers

unread,
Oct 24, 2005, 11:30:12 AM10/24/05
to
Sudip,

We recently moved our LDAP servers behind a firewall and began
experiencing similar behavior. The problem ended up being caused by the
firewall timing out TCP connections after an hour of inactivity. The
pool would try to reuse the closed connections, giving us the same
behavior you described. We just disabled the TCP timouts on the
firewall, because it was also conflicting with the database connection
pools.

Brandon

sudip shrestha

unread,
Oct 24, 2005, 2:42:10 PM10/24/05
to
Brandon:
After Working with my fw-admin here, He fixed that problem (tcp connections being timed out) quite a while ago.  We did not experience that for a while.  Now, it was resurfacing again.  So, I downloaded the source code from http://www.dahbura.com/ldap/, who is the original author of the ConnectionPool: the code you download from his source has some other functions such as refreshing your pool after periodic interval.  I set this interval to be every 3 hrs, and I found that some of those unused connections go dead and they get refreshed.
However, you can check right before giving the connection object whether it is connected or not by adding the following code segment inside the function "protected LDAPConnection getConnFromPool()":

        if ( ldapconnobj != null )
        {
            con = ldapconnobj.getLDAPConn();

            /*start->Added segment*******************/
            if ( !con.isConnected() )
            {
                System.out.println ( "connection (while retrieving connection) is not connected, attempting reconnect before handoff." );
                try {
                    con.reconnect();
                    //reset the ldapconnobj's LDAPConnection parameter
                    ldapconnobj.setLDAPConn( con );
                    //reset the pool's ldapconnobj parameter
                    pool.set( i,ldapconnobj );
                } catch (LDAPException e) {
                        debug("Unable to reconnect - server is probably down");
                }
                System.out.println( "reconnect succeeded." );
            }
            /*end->Added segment*******************/
        }
           
This will reconnect right before
Right now, I am still working with my fw-admin on finding out why some of those connections get disconnected every now and then.

sudip shrestha

unread,
Oct 24, 2005, 2:47:01 PM10/24/05
to
in the previous email, i is the index of LDAPConnectionObject in the actual pooll (ConnectionPool), it can be obtained by moving the declaration of int i outside the for loop in the same function: such as
        // Get an available connection
        int i;
        for (i = 0; i < pSize; i++ )
        {
            // Get the ConnectionObject from the pool
            LDAPConnectionObject co =  (LDAPConnectionObject)pool.get(i);
            .......

ShuhChang

unread,
Jan 9, 2006, 5:57:02 PM1/9/06
to
I am not sure how Netscape internally handles the dropped connections by the LDAP server, but I experienced similar thing using Novell's JLDAP driver. Basically, rather than the firewall dropping the connections, the LDAP server could also timeout and dropped the connection. Please see my discussion below for details on this issue. The PoolManager in Novell's JLDAP is equivalent to Netscape's ConnectionPool.

http://forge.novell.com/modules/xfmod/newsportal/article.php?group_id=1107&msg_id=1391&group=novell.devsup.ldap_j

Regards,
Shuh Chang
shuh dot chang at gmail dot com
"sudip shrestha" <sud...@gmail.com> wrote in message news:mailman.1130179681.14...@mozilla.org...

Sonia18Hayden

unread,
Dec 27, 2011, 5:09:48 AM12/27/11
to
freelance writer


0 new messages