docs: def connect(self, channel):
          """
          In the write-thread we detect that no connection is living anymore and try always again.
          Up to the 3 connection try, we report to user. We keep trying but in silence.
          Also, when more than 10 connection tries are detected, we delay extra 15 seconds.
          """
          if self.connection_tries > 10:
              time.sleep(10)
  
          if self.in_connecting[channel]:
              return False
  
          self.in_connecting[channel] = True
  
          self.logger.debug('[%s] Wanna connect ...' % (channel, ))
  
          try:
              if self.is_connected(channel) or self.online is False:
                  if self.is_connected(channel):
                      self.logger.debug('[%s] Already connected' % (channel, ))
                  if self.online is False:
                      self.logger.debug('[%s] self.online=False' % (channel, ))
  
                  return True
  
              self.channel_lock[channel].acquire()
  
              self.connected[channel] = None
              self.registered[channel] = None
              self.ssh_stream[channel] = False
              self.ssh_channel[channel] = False
              messages = None
              stderrdata = ''
  
              try:
                  if not self.ssh_stream[channel]:
                      self.logger.debug('[%s] Open ssh connection' % (channel, ))
                      self.ssh_stream[channel] = create_ssh_stream(self.config, exit_on_failure=False)
  
                  self.logger.debug('[%s] open channel' % (channel, ))
  
                  self.ssh_channel[channel] = self.ssh_stream[channel].get_transport().open_session()
                  self.ssh_channel[channel].exec_command('stream')
              except (KeyboardInterrupt, SystemExit):
                  raise
              except Exception as e:
                  self.connected[channel] = False
                  self.registered[channel] = False
                  self.logger.debug('[%s] connection failed: %s'  % (channel, str(e)))
                  return False
              finally:
                  self.channel_lock[channel].release()
  
              if self.ssh_channel[channel]:
                  messages = self.wait_for_at_least_one_message(channel)
  
              if not messages:
                  stderrdata = self.ssh_channel[channel].recv_stderr().decode("utf-8").strip()
                  self.connected[channel] = False
                  self.registered[channel] = False
              else:
                  self.logger.debug('[%s] opened and received %d messages' % (channel, len(messages)))
                  self.connected[channel] = True
                  self.registered[channel] = self.on_connect(self.was_connected_once[channel], channel)
                  self.connected_since[channel] = time.time()
  
                  if channel == '' and self.registered[channel] and self.was_connected_once[channel]:
                      self.logger.info("Successfully reconnected.")
  
              if not self.registered[channel]:
                  # make sure to close channel and connection first
                  try:
                      self.ssh_channel[channel] and self.ssh_channel[channel].close()
                  except: pass
  
                  try:
                      self.ssh_stream[channel] and self.ssh_stream[channel].close()
                  except: pass
  
                  self.logger.debug("[%s] Client: registration failed. stderrdata: %s" % (channel, stderrdata))
                  self.connected[channel] = False
  
                  try:
                      self.logger.debug('[%s] Client: ssh_tream close due to registration failure' % (channel, ))
                      self.ssh_stream[channel].close()
                  except (KeyboardInterrupt, SystemExit):
                      raise
  
                  self.connection_tries += 1
                  if not self.was_connected_once[channel] and self.go_offline_on_first_failed_attempt:
                      # initial try needs to be online, otherwise we go offline
                      self.go_offline()
  
                  if stderrdata:
                      if 'Connection refused' not in stderrdata and 'Permission denied' not in stderrdata:
                          self.logger.error(stderrdata)
  
                  if 'Permission denied' in stderrdata:
                      if self.connection_tries < 3:
                          self.logger.warning("Access denied. Did you setup your SSH public key correctly "
                                              "and saved it in your AETROS Trainer user account?")
  
                      self.close()
                      sys.exit(1)
  
                  self.connection_error(channel, "Connection error during connecting to %s: %s" % (self.host, str(stderrdata)))
              else:
                  self.was_connected_once[channel] = True
  
          except Exception as error:
              self.connection_error(channel, error)
          finally:
              self.in_connecting[channel] = False
  
          return self.is_connected(channel)