in src/identity/Common/Utilities/RetryUtilities.cs [33:97]
public static bool IsRetryableException(this Exception e)
{
if (IsTaskCancelledException(e))
{
return true;
}
if (e is HttpOperationException he && he.Response != null)
{
if (IsRetryableHttpStatusCode(he.Response.StatusCode))
{
return true;
}
}
var socketException = FindFirstExceptionOfType<SocketException>(e);
if (socketException != null &&
SocketErrorCodes.Contains(socketException.SocketErrorCode))
{
return true;
}
// Seen Name or service not known error due to DNS resolution failures.
if (socketException != null &&
socketException.Message.StartsWith("Name or service not known"))
{
return true;
}
var webException = FindFirstExceptionOfType<WebException>(e);
if (webException != null)
{
if (WebExceptionStatus.Contains(webException.Status))
{
return true;
}
if (webException.Status == System.Net.WebExceptionStatus.ProtocolError)
{
if (webException.Response is HttpWebResponse response &&
IsRetryableHttpStatusCode(response.StatusCode))
{
return true;
}
}
}
return false;
static bool IsRetryableHttpStatusCode(HttpStatusCode code)
{
switch (code)
{
case HttpStatusCode.InternalServerError:
case HttpStatusCode.Conflict:
case HttpStatusCode.ServiceUnavailable:
case HttpStatusCode.RequestTimeout:
case HttpStatusCode.GatewayTimeout:
case HttpStatusCode.BadGateway:
return true;
}
return false;
}
}