handle connection failures gracefully