diff --git a/SpotifyAPI/Web/SpotifyWebAPI.cs b/SpotifyAPI/Web/SpotifyWebAPI.cs index 2a8059c3..9332ddbb 100644 --- a/SpotifyAPI/Web/SpotifyWebAPI.cs +++ b/SpotifyAPI/Web/SpotifyWebAPI.cs @@ -53,7 +53,7 @@ namespace SpotifyAPI.Web /// /// Should a failed request (Error 500, 502, or 503) be automatically retried or not. /// - public bool UseAutoRetry { get; set; } = false; + public bool UseAutoRetry { get; set; } = true; /// /// Maximum number of tries for one failed request. @@ -1834,6 +1834,7 @@ namespace SpotifyAPI.Web ListResponse data = null; do { + if (data != null) { System.Threading.Thread.Sleep(RetryAfter); } Tuple res = DownloadDataAlt(url); data = ExtractDataFromAltDownload(res); @@ -1854,6 +1855,7 @@ namespace SpotifyAPI.Web ListResponse data = null; do { + if (data != null) { await Task.Delay(RetryAfter); } Tuple res = await DownloadDataAltAsync(url); data = ExtractDataFromAltDownload(res); @@ -1898,6 +1900,7 @@ namespace SpotifyAPI.Web WebClient.SetHeader("Authorization", TokenType + " " + AccessToken); WebClient.SetHeader("Content-Type", "application/json"); + if (response != null) { System.Threading.Thread.Sleep(RetryAfter); } response = WebClient.UploadJson(url, uploadData, method); response.Item2.AddResponseInfo(response.Item1); @@ -1924,6 +1927,7 @@ namespace SpotifyAPI.Web WebClient.SetHeader("Authorization", TokenType + " " + AccessToken); WebClient.SetHeader("Content-Type", "application/json"); + if (response != null) { await Task.Delay(RetryAfter); } response = await WebClient.UploadJsonAsync(url, uploadData, method); response.Item2.AddResponseInfo(response.Item1); @@ -1944,6 +1948,7 @@ namespace SpotifyAPI.Web Tuple response = null; do { + if(response != null) { System.Threading.Thread.Sleep(RetryAfter); } response = DownloadDataAlt(url); response.Item2.AddResponseInfo(response.Item1); @@ -1965,6 +1970,7 @@ namespace SpotifyAPI.Web Tuple response = null; do { + if (response != null) { await Task.Delay(RetryAfter); } response = await DownloadDataAltAsync(url); response.Item2.AddResponseInfo(response.Item1);