code: @Override
      protected void connectInternal() throws SmackException, IOException, XMPPException, InterruptedException {
          closingStreamReceived.init();
          // Establishes the TCP connection to the server and does setup the reader and writer. Throws an exception if
          // there is an error establishing the connection
          connectUsingConfiguration();
  
          // We connected successfully to the servers TCP port
          initConnection();
  
          // TLS handled will be successful either if TLS was established, or if it was not mandatory.
          tlsHandled.checkIfSuccessOrWaitOrThrow();
  
          // Wait with SASL auth until the SASL mechanisms have been received
          saslFeatureReceived.checkIfSuccessOrWaitOrThrow();
      }
docs: Establishes a connection to the XMPP server. It basically
  creates and maintains a socket connection to the server.
  <p>
  Listeners will be preserved from a previous connection if the reconnection
  occurs after an abrupt termination.
  </p>
  
  @throws XMPPException if an error occurs while trying to establish the connection.
  @throws SmackException
  @throws IOException
  @throws InterruptedException