1.     private void keepTrying(final Bootstrap b) {
  2.         b.connect().addListener(new ChannelFutureListener() {
  3.             @Override
  4.             public void operationComplete(ChannelFuture cf) throws Exception {
  5.                 if(cf.isSuccess()) {
  6.                     System.out.println("Connected successfully");
  7.                 } else {
  8.                     Thread.sleep(10*1000);
  9.                     System.out.println("connection attempt failed, econnecting");
  10.                     b.connect().addListener(this);
  11.                 }
  12.             }
  13.         });
  14.     }