Check that all clients respond to the heartbeat in time
559026
function checkClientsHeartbeat() {
    var now = Date.now();
    _.forOwn(_this.socks, function (sock) {
      if (sock.hb + _this.clientTimeout < now) {
        logout(sock);
      }
    });
    setTimeout(checkClientsHeartbeat, 1000)
  }
567929
def send_heartbeat(self, name):
        

        return self._loop.run_coroutine(self._client.send_heartbeat(name))
404780
public boolean checkHeartbeatInfo(HeartbeatArgs jtInfo) {
    if (expectedInfo.requestId != jtInfo.requestId){
      LOG.fatal("heartbeat out-of-sync:" + sessionId + 
        " CM:" + expectedInfo.requestId + " " + expectedInfo.grantId +
        " JT:" + jtInfo.requestId + " " + jtInfo.grantId);
      return false;
    }
    if (expectedInfo.grantId == jtInfo.grantId){
      // perfect match
      if (LOG.isDebugEnabled()) {
        LOG.debug("heartbeat match:" + sessionId); 
      }
      lastSyncTime = System.currentTimeMillis();
      lastHeartbeat.requestId = 0;
      lastHeartbeat.grantId = 0;
      return true;
    }
    // delay
    if ( jtInfo.grantId != lastHeartbeat.grantId) {
      LOG.info("heartbeat mismatch with progress:" + sessionId + 
        " CM:" + expectedInfo.requestId + " " + expectedInfo.grantId +
        " JT:" + jtInfo.requestId + " " + jtInfo.grantId);
      lastSyncTime = System.currentTimeMillis();
      lastHeartbeat.requestId = jtInfo.requestId;
      lastHeartbeat.grantId = jtInfo.grantId;
      return true;
    }
    if (System.currentTimeMillis() - lastSyncTime > maxDelay) {
      // no progress
      LOG.error("heartbeat out-of-sync:" + sessionId + 
        " CM:" + expectedInfo.requestId + " " + expectedInfo.grantId +
        " JT:" + jtInfo.requestId + " " + jtInfo.grantId);
      return true;
    }
    LOG.info("heartbeat mismatch with no progress:" + sessionId + 
      " CM:" + expectedInfo.requestId + " " + expectedInfo.grantId +
      " JT:" + jtInfo.requestId + " " + jtInfo.grantId);
    return true;
  }
1141998
def heartbeat(self):
        
        unique_id = self.new_unique_id()
        message = {
            'op': 'heartbeat',
            'id': unique_id,
        }
        self._send(message)
        return unique_id
514224
def handle_heartbeat_response(msg):
    """"""
    if not msg.gateway.is_sensor(msg.node_id):
        return None
    handle_smartsleep(msg)
    msg.gateway.sensors[msg.node_id].heartbeat = msg.payload
    msg.gateway.alert(msg)
    return None
753107
def request_check_all(self, wait_time=5):
        """"""
        with self._lock:
            self._request_check_all()
            self._condition.wait(wait_time)
682944
function heartbeat() {
      Instance.db.updateOne(
        {
          _id: instanceId
        },
        {
          $set: { lastAliveOn: new Date() }
        },
        {
          upsert: true
        }
      );
    }
526110
function _check(){
            if(_checkReady(target)){
                clearInterval(timeHandle);
                timeHandle = null;
                _call();

                isReady = true;
            }               
        }
144992
def check_all_servers():
    """"""
    data = datatools.get_data()
    for server_id in data["discord"]["servers"]:
        is_in_client = False
        for client_server in client.servers:
            if server_id == client_server.id:
                is_in_client = True
                break

        if not is_in_client:
            remove_server_data(server_id)
476092
def heartbeat(self):
        ''''''
        logger.debug('Heartbeating %s (ttl = %s)', self.jid, self.ttl)
        try:
            self.expires_at = float(self.client('heartbeat', self.jid,
            self.client.worker_name, json.dumps(self.data)) or 0)
        except QlessException:
            raise LostLockException(self.jid)
        logger.debug('Heartbeated %s (ttl = %s)', self.jid, self.ttl)
        return self.expires_at
561642
public void sessionHeartbeat(long sessionId) {
    synchronized (mSessions) {
      if (mSessions.containsKey(sessionId)) {
        mSessions.get(sessionId).heartbeat();
      } else {
        int sessionTimeoutMs = (int) ServerConfiguration
            .getMs(PropertyKey.WORKER_SESSION_TIMEOUT_MS);
        mSessions.put(sessionId, new SessionInfo(sessionId, sessionTimeoutMs));
      }
    }
  }
1196788
def heartbeat(request):
    
    all_checks = checks.registry.registry.get_checks(
        include_deployment_checks=not settings.DEBUG,
    )

    details = {}
    statuses = {}
    level = 0

    for check in all_checks:
        detail = heartbeat_check_detail(check)
        statuses[check.__name__] = detail['status']
        level = max(level, detail['level'])
        if detail['level'] > 0:
            details[check.__name__] = detail

    if level < checks.messages.WARNING:
        status_code = 200
        heartbeat_passed.send(sender=heartbeat, level=level)
    else:
        status_code = 500
        heartbeat_failed.send(sender=heartbeat, level=level)

    payload = {
        'status': level_to_text(level),
        'checks': statuses,
        'details': details,
    }
    return JsonResponse(payload, status=status_code)
1213593
def on_send(self, frame):
        
        if frame.cmd == CMD_CONNECT or frame.cmd == CMD_STOMP:
            if self.heartbeats != (0, 0):
                frame.headers[HDR_HEARTBEAT] = '%s,%s' % self.heartbeats
        if self.next_outbound_heartbeat is not None:
            self.next_outbound_heartbeat = monotonic() + self.send_sleep
1170493
def heartbeat_tick(self, rate=2):
        
        if not self.heartbeat:
            return

        # treat actual data exchange in either direction as a heartbeat
        sent_now = self.method_writer.bytes_sent
        recv_now = self.method_reader.bytes_recv
        if self.prev_sent is None or self.prev_sent != sent_now:
            self.last_heartbeat_sent = monotonic()
        if self.prev_recv is None or self.prev_recv != recv_now:
            self.last_heartbeat_received = monotonic()
        self.prev_sent, self.prev_recv = sent_now, recv_now

        # send a heartbeat if it's time to do so
        if monotonic() > self.last_heartbeat_sent + self.heartbeat:
            self.send_heartbeat()
            self.last_heartbeat_sent = monotonic()

        # if we've missed two intervals' heartbeats, fail; this gives the
        # server enough time to send heartbeats a little late
        if (self.last_heartbeat_received and
                self.last_heartbeat_received + 2 *
                self.heartbeat < monotonic()):
            raise ConnectionForced('Too many heartbeats missed')
956734
def Wait(self, timeout):
    """"""
    time.sleep(timeout - int(timeout))

    # Split a long sleep interval into 1 second intervals so we can heartbeat.
    for _ in range(int(timeout)):
      time.sleep(1)

      if self.heart_beat_cb:
        self.heart_beat_cb()
246604
function(opts) {
  opts = opts || {};
  this.heartbeat = null;
  this.timeout = null;
  this.disconnectOnTimeout = opts.disconnectOnTimeout;

  if(opts.heartbeat) {
    this.heartbeat = opts.heartbeat * 1000; // heartbeat interval
    this.timeout = opts.timeout * 1000 || this.heartbeat * 2;      // max heartbeat message timeout
    this.disconnectOnTimeout = true;
  }

  this.timeouts = {};
  this.clients = {};
}
924202
def start_heartbeat(self):
        """"""
        self.stop_heartbeat()

        self._heartbeat_timer = periodic.Callback(self._heartbeat,
                                                  self._heartbeat_interval,
                                                  self.server.io_loop)
        self._heartbeat_timer.start()