Browse Source

Improved handling of SSL/TLS error

tags/docs-0.9
RogueException 9 years ago
parent
commit
60610abe5d
1 changed files with 3 additions and 7 deletions
  1. +3
    -7
      src/Discord.Net/Net/Rest/SharpRestEngine.cs

+ 3
- 7
src/Discord.Net/Net/Rest/SharpRestEngine.cs View File

@@ -52,19 +52,15 @@ namespace Discord.Net.Rest
} }
private async Task<string> Send(RestRequest request, CancellationToken cancelToken) private async Task<string> Send(RestRequest request, CancellationToken cancelToken)
{ {
bool hasRetried = false;
int retryCount = 0;
while (true) while (true)
{ {
var response = await _client.ExecuteTaskAsync(request, cancelToken).ConfigureAwait(false); var response = await _client.ExecuteTaskAsync(request, cancelToken).ConfigureAwait(false);
int statusCode = (int)response.StatusCode; int statusCode = (int)response.StatusCode;
if (statusCode == 0) //Internal Error if (statusCode == 0) //Internal Error
{ {
if (!hasRetried)
{
//SSL/TTS Error seems to work if we immediately retry
hasRetried = true;
continue;
}
if (response.ErrorException.HResult == -2146233079 && retryCount++ < 5) //The request was aborted: Could not create SSL/TLS secure channel.
continue; //Seems to work if we immediately retry
throw response.ErrorException; throw response.ErrorException;
} }
if (statusCode < 200 || statusCode >= 300) //2xx = Success if (statusCode < 200 || statusCode >= 300) //2xx = Success


Loading…
Cancel
Save