code: private synchronized void tryToReConnect() {
          if (!autoReConnect) return;
          mScheduleTaskExecutor = Executors.newSingleThreadScheduledExecutor();
          mScheduleTaskExecutor.scheduleAtFixedRate(new Runnable() {
              @Override
              public void run() {
                  try {
                      connectToServer();
                      removeTryToReConnect();
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
          }, 3, 3, TimeUnit.SECONDS);
      }
docs: Reconnection