Added retries in case of connection failure.