'identity.api.rackspacecloud.com' 随机抛出 'The remote name could not be resolved' 异常

'identity.api.rackspacecloud.com' randomly throws 'The remote name could not be resolved' exception

我正在访问 Rackspace 云 API。

我有一个 api 调用可以在 rackspace 云上验证我的身份。

该方法非常有效,但是,我有时会收到此异常,随机 :

The remote name could not be resolved: 'identity.api.rackspacecloud.com'

当我没有得到这个异常时,方法 returns 预期的结果,因为它应该是。

这样做有什么具体原因吗?

这是我的 .net 代码:

private async Task<XDocument> AuthenticateAsync()
{
    XNamespace ns = "http://docs.rackspace.com/identity/api/ext/RAX-KSKEY/v1.0";

    XDocument doc =
        new XDocument(
            new XDeclaration("1.0", "UTF-8", "Yes"),
            new XElement("auth",
                new XElement(ns + "apiKeyCredentials",
                    new XAttribute("username", "the userName"),
                    new XAttribute("apiKey", "the apiKey")
                )
            )
        );

    using (HttpClient client = new HttpClient())
    {
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));

        StringContent content = new StringContent(doc.ToString(), Encoding.UTF8, "application/xml");

        // i randomly get "The remote name could not be resolved" exception
        HttpResponseMessage response = await client.PostAsync("https://identity.api.rackspacecloud.com/v2.0/tokens", content);
        response.EnsureSuccessStatusCode();

        string stringResponse = await response.Content.ReadAsStringAsync();
        return XDocument.Parse(stringResponse);
    }
}

这听起来确实像是 DNS 故障。你能配置你的机器使用 Google DNS servers 然后再试一次吗?