java - How to reduced timeout exception on AD host unreachable time using unboundid SDK? -
i using unboundid sdk ad server authentication
public static boolean adauthentication(string ldapurl, int ldapport, string bindusername, string bindpassword) { sslutil sslutil = new sslutil(null, new trustalltrustmanager()); socketfactory socketfactory; ldapconnection ldapconnection = null; boolean isauthentic = null; try { socketfactory = sslutil.createsslsocketfactory(); ldapconnectionoptions options = new ldapconnectionoptions(); options.setabandonontimeout(true); **options.setresponsetimeoutmillis(10000); options.setconnecttimeoutmillis(10000);** ldapconnection = new ldapconnection(socketfactory, ldapurl, ldapport); ldapconnection.setconnectionoptions(options); if(ldapconnection.isconnected()){ final bindrequest bindrequest = new simplebindrequest(bindusername, bindpassword); final bindresult bindresult = ldapconnection.bind(bindrequest); final resultcode resultcode = bindresult.getresultcode(); isauthentic = resultcode.equals(resultcode.success) ? true : false; ldapconnection.close(); } } catch (ldapexception ldapexception) { logger.error("ad host exception ::: "+ ldapexception); } catch (generalsecurityexception exception) { logger.error("ad security exception ::: " + exception); }finally{ if(ldapconnection!= null) ldapconnection.close(); } return isauthentic; } this code working fine on ad server reachable time suppose ad server unreachable mean throw following error after 60 seconds
"ad host exception ::: ldapexception(resultcode=91 (connect error), errormessage='an error occurred while attempting connect server 000.000.00.00:369: java.io.ioexception: unable establish connection server 000.000.00.00:369 within configured timeout of 60000 milliseconds.')"
but needed throw error within 20 seconds. set timeout limit follow no effect. options.setresponsetimeoutmillis(20000); options.setconnecttimeoutmillis(20000);
thanks.
since you're providing connection information in constructor, constructor establishing connection. however, you're not setting connection options until after constructor, constructor using default connection options.
rather using ldapconnection(socketfactory,string,int) constructor, should use ldapconnection(socketfactory,ldapconnectionoptions,string,int) constructor. cause connection establishment use provided connection options instead of default.
Comments
Post a Comment