JDK-6446585 : Client is hanging when using non LDAP port
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.naming
  • Affected Version: beta2
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2006-07-06
  • Updated: 2010-07-29
  • Resolved: 2008-04-07
Related Reports
Duplicate :  
Description
I have a client application which is using JNDI to establish a connection to a LDAP Server. When I specify a non LDAP port, namely port 25, my client application is hanging. At that point, the client stack looks like:

 - java.lang.Object.wait(long)
 - com.sun.jndi.ldap.Connection.readReply line=418 
 - com.sun.jndi.ldap.LdapClient.ldapBind line=340 
 - com.sun.jndi.ldap.LdapClient.authenticate line=192 
 - com.sun.jndi.ldap.LdapCtx.connect line=2637 
 - com.sun.jndi.ldap.LdapCtx.ensureOpen line=2546 
 - com.sun.jndi.ldap.LdapCtx.ensureOpen line=2520 
 - com.sun.jndi.ldap.LdapCtx.reconnect line=2516 
 - javax.naming.ldap.InitialLdapContext.reconnect line=173 
 - com.sun.directory.common.LDAPConnectionCenter.getLdapConnection line=160 
 [...]

Port 25 is the well-known port for SMTP.

Comments
EVALUATION Thx for the workaround :-)
06-07-2006

WORK AROUND For releases prior to mustang, there is no elegant work around for this problem. The applications can, however keep a timer that interrupts the JNDI call in question. class MyJNDIApp { ...... try { TimeKeeper timer = new TimeKeeper(30000); // timeout of 30 secs. DirContext ctx = new InitialDirContext(env); .... } catch (InterruptedException ie) { // Handle time out action } ...... } class TimeKeeper extends Thread { long timeout; // in milliseconds long timerStart; Thread parent; TimeKeeper(long timeout) { parent = Thread.currentThread(); this.timeout = timeout; this.start(); } public static void start(long timeout) { new TimeKeeper(timeout); } public void run() { timerStart = System.currentTimeMillis(); long waitTime = timeout; while (waitTime > 0) { try { this.sleep(waitTime); } catch (InterruptedException ie) { // ignore and continue } waitTime = timeout - (System.currentTimeMillis() - timerStart); System.out.println(waitTime); } parent.interrupt(); } }
06-07-2006

EVALUATION Hi jayalaxmi, Thx for the quick update. The upcoming release of DSEE6.0 (DS and DPS products) will be supported on Java 5 only. Is there a way to workaround this issue without Mustang?
06-07-2006

EVALUATION A new environment property introduced in mustang Java SE 6 can be used to prevent the client hang. The environment property: "com.sun.jndi.ldap.read.timeout" can be used to specify the timeout while waiting for the server to respond to a request. For more information check the blog: http://blogs.sun.com/jaya_hangal (scroll down to LDAP read timeout section)
06-07-2006