code: def _check_connection(self):
          
          # check if connection is expired
          reset = False
          if self._force_recon:
              self.logger.warning(
                  "[%s:%s] Error communicating with socket, resetting "
                  "connection",
                  self.fn or self.host, self.port)
              reset = True
  
          elif self.heartbeat_controller.is_expired():
              self.logger.warning(
                  "[%s:%s] Heartbeat timeout, resetting connection",
                  self.fn or self.host, self.port)
              reset = True
  
          if reset:
              for channel in self._open_channels:
                  self.disconnect_channel(channel)
              self._report_connection_status(
                  ConnectionStatus(CONNECTION_STATUS_LOST,
                                   NetworkAddress(self.host, self.port)))
              try:
                  self.initialize_connection()
              except ChromecastConnectionError:
                  self.stop.set()
              return False
          return True
docs: Checks if the connection is active, and if not reconnect
  
          :return: True if the connection is active, False if the connection was
                   reset.