Added the ability to keep trying to connect until successful