# File lib/swiftcore/Analogger/Client.rb, line 200
      def connect
        @socket = open_connection(@host, @port)
        authenticate
        raise FailedToAuthenticate(@host, @port) unless authenticated?
        clear_failure

        if there_is_a_swamp?
          drain_the_swamp
        else
          setup_remote_logging
        end

      rescue Exception => e
        register_failure
        close_connection
        setup_reconnect_thread unless @reconnection_thread && Thread.current == @reconnection_thread
        setup_local_logging
        raise e if fail_connect?
      end