protected void sendHeartBeat() {
   String request =
       FactoryManagerUtils.getStringProperty(
           session,
           ClientFactoryManager.HEARTBEAT_REQUEST,
           ClientFactoryManager.DEFAULT_KEEP_ALIVE_HEARTBEAT_STRING);
   try {
     Buffer buf = session.createBuffer(SshConstants.SSH_MSG_GLOBAL_REQUEST);
     buf.putString(request);
     buf.putBoolean(false);
     session.writePacket(buf);
   } catch (IOException e) {
     log.info("Error sending keepalive message=" + request, e);
   }
 }
 protected void startHeartBeat() {
   long interval =
       FactoryManagerUtils.getLongProperty(
           session,
           ClientFactoryManager.HEARTBEAT_INTERVAL,
           ClientFactoryManager.DEFAULT_HEARTBEAT_INTERVAL);
   if (interval > 0L) {
     FactoryManager manager = session.getFactoryManager();
     ScheduledExecutorService service = manager.getScheduledExecutorService();
     service.scheduleAtFixedRate(
         new Runnable() {
           @Override
           public void run() {
             sendHeartBeat();
           }
         },
         interval,
         interval,
         TimeUnit.MILLISECONDS);
     if (log.isDebugEnabled()) {
       log.debug("startHeartbeat - started at interval={}", Long.valueOf(interval));
     }
   }
 }