Automatically retrying curl error 65 and ensuring retries are not performed more than 3 times