@@ -379,23 +379,25 @@ private boolean waitForConnection(long timeout, TimeUnit units) throws Interrupt
379
379
}
380
380
381
381
private void openChannel (ClientMessageChannel channel ) throws InterruptedException {
382
+ long waitTime = 0 ;
382
383
while (!clientStopped .isSet ()) {
383
384
try {
385
+ waitTime = Math .min (Math .max (Math .round (waitTime * 1.5 ), 1_000L ), 30_000L );
384
386
DSO_LOGGER .debug ("Trying to open channel...." );
385
387
channel .open (serverAddresses );
386
388
DSO_LOGGER .debug ("Channel open" );
387
389
break ;
388
390
} catch (final TCTimeoutException tcte ) {
389
- DSO_LOGGER .debug ("Unable to connect to server/s {} ...sleeping for 1 sec." , serverAddresses );
391
+ DSO_LOGGER .info ("Unable to connect to server/s {} ...sleeping for {} sec." , serverAddresses , TimeUnit . MILLISECONDS . toSeconds ( waitTime ) );
390
392
DSO_LOGGER .debug ("Timeout connecting to server/s: {} {}" , serverAddresses , tcte .getMessage ());
391
393
synchronized (clientStopped ) {
392
- clientStopped .wait (1000 );
394
+ clientStopped .wait (waitTime );
393
395
}
394
396
} catch (final ConnectException e ) {
395
- DSO_LOGGER .debug ("Unable to connect to server/s {} ...sleeping for 1 sec." , serverAddresses );
397
+ DSO_LOGGER .info ("Unable to connect to server/s {} ...sleeping for {} sec." , serverAddresses , TimeUnit . MILLISECONDS . toSeconds ( waitTime ) );
396
398
DSO_LOGGER .debug ("Connection refused from server/s: {} {}" , serverAddresses , e .getMessage ());
397
399
synchronized (clientStopped ) {
398
- clientStopped .wait (1000 );
400
+ clientStopped .wait (waitTime );
399
401
}
400
402
} catch (final MaxConnectionsExceededException e ) {
401
403
DSO_LOGGER .error (e .getMessage ());
@@ -407,15 +409,15 @@ private void openChannel(ClientMessageChannel channel) throws InterruptedExcepti
407
409
DSO_LOGGER .error (handshake .getMessage ());
408
410
throw new IllegalStateException (handshake .getMessage (), handshake );
409
411
} catch (final IOException ioe ) {
410
- DSO_LOGGER .debug ("Unable to connect to server/s {} ...sleeping for 1 sec." , serverAddresses );
412
+ DSO_LOGGER .info ("Unable to connect to server/s {} ...sleeping for {} sec." , serverAddresses , TimeUnit . MILLISECONDS . toSeconds ( waitTime ) );
411
413
DSO_LOGGER .debug ("IOException connecting to server/s: {} {}" , serverAddresses , ioe .getMessage ());
412
414
synchronized (clientStopped ) {
413
- clientStopped .wait (1000 );
415
+ clientStopped .wait (waitTime );
414
416
}
415
417
}
416
418
}
417
419
}
418
-
420
+
419
421
private void waitForHandshake (ClientMessageChannel channel ) {
420
422
this .clientHandshakeManager .waitForHandshake ();
421
423
ClientMessageChannel cmc = this .getClientMessageChannel ();
0 commit comments