connection.isOpen still true while there is a connectiion exception

31 views
Skip to first unread message

Sergey Vatarmin

unread,
Dec 10, 2017, 5:22:40 PM12/10/17
to ldaptive
Hello,
Seems like I don't understand something from the documentation. I create a connection and execute BindOperation and on each new LDAP query I check whether connection is still open. If false I reconnect. Otherwise execute query. The problem is that after about 20 minutes of the successful work, isOpen still returns true but an exception start to be thrown saying that a successful bind must be completed on the connection. Is it a bug in the library or I miss something?

                conn = DefaultConnectionFactory.getConnection(connConfig);
                conn.open();
                final BindOperation bind = new BindOperation(conn);
                bind..execute(new BindRequest(config.getLDAPConnectionUsername(), new Credential(config.getLDAPConnectionPassword())));

Daniel Fisher

unread,
Dec 11, 2017, 10:04:29 AM12/11/17
to ldap...@googlegroups.com
Connection#isOpen tells you whether a successful invocation to Connection#open was made.
It doesn't tell you about the current state of the connection.
In your case, it sounds like the LDAP or some network device is tearing down the connection after some timeout.

By default a reopen exception handler is configured to reopen the connection in this sort of circumstance.
If you configure a BindConnectionInitializer you should see your connections reestablish and bind correctly.

Another alternative is to use pooling and configure your pool to validate connections in order to keep them alive.
Lastly, you could investigate the client and server keep-alive settings.
Sometimes a simple tweak to your TCP config can solve this issue.

--Daniel Fisher

--
You received this message because you are subscribed to the Google Groups "ldaptive" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ldaptive+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages