Fixed loop in connection retry logic