Aiming for 24X7: Failover and Reconnecting

The LDAPConnection.connect methods can take more than just a host name or IP address for the host name parameter. The parameter can be a space-delimited list of hosts, with an optional colon and port number for each—for example:

      String hosts =
         "directory.knowledge.com:1050 people.catalog.com 199.254.1.2";
      ld.connect( hosts, 20000 );

In this example, three alternative hosts are specified. The first one also has the port number identified; the second and third ones will use the port number passed as the second parameter to the method: 20000. The SDK will attempt to connect to the first host in the list. If that fails, it will try the second one, and so on.

You can tune the connection policy with LDAPConnection.setConnSetupDelay ...

Get LDAP Programming with Java™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.