Solved

Java novell LDAPConnection timeout problem

Posted on 2014-09-18
7
572 Views
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 ldap.zip 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 10.1.1.1 - not on  network - imitate dead LDAP Server
                  ldapConnection.connect("10.1.1.1", 636);
            } catch (LDAPException e) {
                  e.printStackTrace();
            }                                                
      }
}

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


Please help if you have any ideas how to set timeout correctly for com.novell.ldap.LDAPConnection.
ldap.zip
LDAPConnectionTimeOutTest.java
0
Comment
Question by:MehtaJasmin
  • 4
  • 3
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Try
java -Dsun.net.client.defaultConnectTimeout=5000 NEXLdapConnectionTimeOutTest

Open in new window

0
 

Author Comment

by:MehtaJasmin
Comment Utility
the solution above does not work, still have 21 sec
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
I can't comment really. You'd need to look at the source to find out what's going on
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:MehtaJasmin
Comment Utility
CEHI, did you try to run the program yourself? Is it working for you?
Thank you.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
I had the same problem
0
 

Accepted Solution

by:
MehtaJasmin earned 0 total points
Comment Utility
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.close();
      socket = null;

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

Author Closing Comment

by:MehtaJasmin
Comment Utility
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.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
maven java path setting 5 49
topping2 challenge 13 56
get weblogic logged in user in java 2 40
Java Server Faces parameter pass? 6 18
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now