Java novell LDAPConnection timeout problem

Posted on 2014-09-18
Last Modified: 2014-09-30
Hello, Experts,
I'm trying to set timeout value in constructor and also by using LDAPConnection.setSocketTimeOut( ) method to 5 sec  in case if LDAP server is dead, it should throw LDAPException in 5 sec, but instead it waits for 21 sec in WIndows and 63 sec in Linux - no matter what value you pass in constructor or setSocketTimeOut( ) method, Please see the code below or in attachements:
Note: Please rename attached to ldap.jar and add it  to your CLASSPATH
==========================  START   ==========================================

import com.novell.ldap.LDAPConnection;
import com.novell.ldap.LDAPException;

 * Class to test the timeout issue with novell LDAPConnection.
 * @author Max G
public class NEXLdapConnectionTimeOutTest {

       * @param args
      public static void main(String[] args) {
            //Constructs a new LDAPConnection object, which will use the supplied timeout value (in MILLI SECONDS)
            //NO MATTER WHAT VALUE YOU PUT - it gives 21 sec in Windows and 1 min in Linux
            LDAPConnection ldapConnection = new LDAPConnection(5000); // 5 sec      
            //ldapConnection.setSocketTimeOut(5000); // Not working either
            try {
                  //Use dummy IP - not on  network - imitate dead LDAP Server
                  ldapConnection.connect("", 636);
            } catch (LDAPException e) {

==========================  END ==========================================

Please help if you have any ideas how to set timeout correctly for com.novell.ldap.LDAPConnection.
Question by:MehtaJasmin
  • 4
  • 3
LVL 86

Expert Comment

ID: 40331697
java NEXLdapConnectionTimeOutTest

Open in new window


Author Comment

ID: 40333207
the solution above does not work, still have 21 sec
LVL 86

Expert Comment

ID: 40333251
I can't comment really. You'd need to look at the source to find out what's going on
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.


Author Comment

ID: 40333318
CEHI, did you try to run the program yourself? Is it working for you?
Thank you.
LVL 86

Expert Comment

ID: 40333846
I had the same problem

Accepted Solution

MehtaJasmin earned 0 total points
ID: 40344706
Looks like com.novell.ldap library  ldap.jar has a bug. So it's not possible to make it work, instead I was using the java socket to check if LDAP servers are up, the code is below:
try {

      Socket socket= new Socket();
      SocketAddress socketAddress = new InetSocketAddress(sLDAPServerIPPrimary, iLDAPServerPort);
      socket.connect(socketAddress, iTimeout);
      socket = null;

} catch (Exception e) {
      //Throw LDAPException if LDAP Server is down
      throw new LDAPException("======= THIS IS SOCKET TIMEOUT TEST!!!! ===== " + e.getLocalizedMessage(),LDAPException.CONNECT_ERROR, e.getMessage());            

Author Closing Comment

ID: 40351795
Can't make ldap.jar from novell to set timeout, even API documented as you can. Workaround is to use Socket to check  the connection timeout and then user other functionality of novell ldap.jar.

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to parse custom JSON to POJO java 4 73
egit plugin on eclipse 8 63
Opening PDF on button click and fill new document 2 37
Running JavaFX on JDeveloper 12C 1 31
This article will show, step by step, how to integrate R code into a R Sweave document
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question