'identity.api.rackspacecloud.com'随机抛出'远程名称无法解析'异常('identity.api.rackspacecl

编程入门 行业动态 更新时间:2024-10-12 22:31:34
'identity.api.rackspacecloud.com'随机抛出'远程名称无法解析'异常('identity.api.rackspacecloud.com' randomly throws 'The remote name could not be resolved' exception)

我正在访问Rackspace Cloud API。

我有一个api电话,在架空云上验证我。

该方法可以很好地工作,但是,我会不时地得到这个例外:

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

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

这有什么特别的原因吗?

这是我的.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); } }

I am accessing Rackspace Cloud APIs.

I have one api call which authenticates me on the rackspace cloud.

The method works perfectly, however, from time to time, i get this exception, randomly :

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

When i am not getting this exception, the method returns the expected result, as it should be.

Is there any specific reason why it does this?

Here is my .net code:

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服务器并重试?

This certainly sounds like a DNS failure. Can you configure your machine to use the Google DNS servers and try again?

更多推荐

本文发布于:2023-07-30 14:38:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1338856.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:抛出   异常   名称   rackspacecloud   identity

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!