我正在访问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?
更多推荐
发布评论