in aliyun-net-sdk-dybaseapi/Dybaseapi/MNS/Runtime/Pipeline/RetryHandler/DefaultRetryPolicy.cs [87:145]
public override bool RetryForException(IExecutionContext executionContext, Exception exception)
{
// An IOException was thrown by the underlying http client.
if (exception is IOException)
{
// Don't retry IOExceptions that are caused by a ThreadAbortException
if (IsInnerException<ThreadAbortException>(exception))
return false;
// Retry all other IOExceptions
return true;
}
// A AliyunServiceException was thrown by ErrorHandler
var serviceException = exception as AliyunServiceException;
if (serviceException != null)
{
/*
* For 500 internal server errors and 503 service
* unavailable errors, we want to retry, but we need to use
* an exponential back-off strategy so that we don't overload
* a server with a flood of retries. If we've surpassed our
* retry limit we handle the error response as a non-retryable
* error and go ahead and throw it back to the user as an exception.
*/
if (serviceException.StatusCode == HttpStatusCode.InternalServerError ||
serviceException.StatusCode == HttpStatusCode.ServiceUnavailable)
{
return true;
}
/*
* Throttling is reported as a 400 or 503 error from services. To try and
* smooth out an occasional throttling error, we'll pause and retry,
* hoping that the pause is long enough for the request to get through
* the next time.
*/
if ((serviceException.StatusCode == HttpStatusCode.BadRequest ||
serviceException.StatusCode == HttpStatusCode.ServiceUnavailable))
{
string errorCode = serviceException.ErrorCode;
if (this.ErrorCodesToRetryOn.Contains(errorCode))
{
return true;
}
}
WebException webException;
if (IsInnerException<WebException>(exception, out webException))
{
if (this.WebExceptionStatusesToRetryOn.Contains(webException.Status))
{
return true;
}
}
}
return false;
}