Issue 5808 - jldap library connect timeout doesn't work
Summary: jldap library connect timeout doesn't work
Status: UNCONFIRMED
Alias: None
Product: JLDAP
Classification: Unclassified
Component: JLDAP (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-13 11:28 UTC by mavricknzwork@yahoo.com
Modified: 2020-11-04 08:21 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description mavricknzwork@yahoo.com 2008-11-13 11:28:59 UTC
Full_Name: Matt Stevenson
Version: 
OS: Linux
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (62.129.121.62)


I believe trying to timeout using "LDAPConnection(int timeout)" will not work.
The below patch fixes that, with limited testing.

Regards
Matt

I, Matt Stevenson, hereby place the following modifications to OpenLDAP Software
(and only these modifications) into the public domain. Hence, these
modifications may be freely used and/or redistributed for any purpose with or
without attribution and/or other notice.

### Eclipse Workspace Patch 1.0
#P jldap
Index: com/novell/ldap/Connection.java
===================================================================
RCS file: /repo/OpenLDAP/pkg/jldap/com/novell/ldap/Connection.java,v
retrieving revision 1.91
diff -u -r1.91 Connection.java
--- com/novell/ldap/Connection.java	22 Feb 2008 11:29:50 -0000	1.91
+++ com/novell/ldap/Connection.java	13 Nov 2008 11:22:30 -0000
@@ -21,7 +21,7 @@
 import java.net.Socket;
 import java.net.SocketException;
 import java.net.SocketTimeoutException;
-
+import java.net.InetSocketAddress;
 
 import com.novell.ldap.asn1.*;
 import com.novell.ldap.client.*;
@@ -454,7 +454,10 @@
                     }
                     socket = mySocketFactory.createSocket(host, port);
                 } else {
-                	socket = new Socket(host, port);
+                	socket = new Socket();
+                	InetSocketAddress socketAddress = new InetSocketAddress(host,
port);
+                	socket.connect(socketAddress, myTimeOut);
+                	//socket = new Socket(host, port);
                 	if(myTimeOut > 0)
                 	{
                 		socket.setSoTimeout(myTimeOut);

Comment 1 ando@openldap.org 2008-11-22 13:38:05 UTC
changed notes
Comment 2 Howard Chu 2009-01-26 09:08:02 UTC
moved from Incoming to Contrib
Comment 3 OpenLDAP project 2014-08-01 21:03:28 UTC
jldap
Comment 4 Norbert Klasen 2020-11-04 08:19:18 UTC
The same problem can be observed, if a non-default SocketFactory (e.g. for LDAPS connections) is used:

See https://bugs.openldap.org/show_bug.cgi?id=5808 (SocketFactory does not support a connect timeout.)