code: func StartKeepAliveLoop(p KeepAliveParams) {
  	var missedCount int64
  
  	log := logrus.WithFields(logrus.Fields{
  		trace.Component: teleport.ComponentKeepAlive,
  	})
  	log.Debugf("Starting keep-alive loop with with interval %v and max count %v.", p.Interval, p.MaxCount)
  
  	tickerCh := time.NewTicker(p.Interval)
  	defer tickerCh.Stop()
  
  	for {
  		select {
  		case <-tickerCh.C:
  			var sentCount int
  
  			// Send a keep alive message on all connections and make sure a response
  			// was received on all.
  			for _, conn := range p.Conns {
  				ok := sendKeepAliveWithTimeout(conn, defaults.ReadHeadersTimeout, p.CloseContext)
  				if ok {
  					sentCount += 1
  				}
  			}
  			if sentCount == len(p.Conns) {
  				missedCount = 0
  				continue
  			}
  
  			// If enough keep-alives are missed, the connection is dead, call cancel
  			// and notify the server to disconnect and cleanup.
  			missedCount = missedCount + 1
  			if missedCount > p.MaxCount {
  				log.Infof("Missed %v keep-alive messages, closing connection.", missedCount)
  				p.CloseCancel()
  				return
  			}
  		// If an external caller closed the context (connection is done) then no
  		// more need to wait around for keep-alives.
  		case <-p.CloseContext.Done():
  			return
  		}
  	}
  }
docs: // StartKeepAliveLoop starts the keep-alive loop.