Azure 容器实例的 HttpClient 随机异常
HttpClient random exception with Azure Container Instance
HttpClient 使用 Azure 容器实例抛出随机异常(10 次尝试中可能有 2-3 次)
Exception Info: System.Net.WebException at
System.Net.HttpWebRequest.EndGetResponse(System.IAsyncResult) at
System.Net.Http.HttpClientHandler.GetResponseCallback(System.IAsyncResult)
Exception Info: System.Net.Http.HttpRequestException at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at
System.Net.Http.HttpClient+\u003cFinishSendAsync\u003ed__58.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSucem.Net.Http.HttpClient+\u003cFinishSendAsync\u003ed__58.MoveNext()
at
SystetHelpers.MSIResourcesAccessInfoHelper+\u003cGetResourcesAccessInfo\u003ed__0.MoveNext()\n.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\n
at System.Runtime.m[[System.__Canon, mscorlib, Version=4.0.0.0,
Culture=neutral,
PublicKeyToken=b77a5c56193ompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.ThreC.Main(System.String[])
在代码方面,我只是在开火
await httpClient.GetAsync($"http://xyz.eastus.cloudapp.azure.com/api/controller/{id}");
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsAsync<ResourceAccessInfo>();
该行为非常随机,10 次尝试中只会发生 2-3 次
我在第一次尝试时也应用了重试,然后尝试第二次但仍然失败
同样适用于 VM 容器。
已更新:
额外的异常信息:
System.Net.Http.HttpRequestException: 发送请求时出错。 ---\u003e System.Net.WebException: 无法解析远程名称:\u0027cloudbridge1.eastus.cloudapp.azure.com\u0027\r\n 在 System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)\r\n 在 System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)\r\n --- 内部异常堆栈跟踪结束 ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task )\r\n at System.Net.Http.HttpClient.\u003cFinishSendAsync\u003ed__58.MoveNext()\r\n--- 从先前抛出异常的位置开始的堆栈跟踪结束 ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\r\n 在 UcClearly.MSIAPIHelpers.MSIResourcesAccessInfoHelper.\u003cGetResourcesAccessInfo\u003ed__0.MoveNext()
这表明远程服务器 DNS 未解析,我尝试使用服务器的 public IP,但随机行为相同,我不确定为什么 Azure 容器实例以这种随机方式表现
此行为是预期的。
Windows containers slow network readiness
On initial creation, Windows containers may have no inbound or outbound connectivity for up to 30 seconds (or longer, in rare cases). If your container application needs an Internet connection, add delay and retry logic to allow 30 seconds to establish Internet connectivity. After initial setup, container networking should resume appropriately.
HttpClient 使用 Azure 容器实例抛出随机异常(10 次尝试中可能有 2-3 次)
Exception Info: System.Net.WebException at System.Net.HttpWebRequest.EndGetResponse(System.IAsyncResult) at System.Net.Http.HttpClientHandler.GetResponseCallback(System.IAsyncResult) Exception Info: System.Net.Http.HttpRequestException at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) at System.Net.Http.HttpClient+\u003cFinishSendAsync\u003ed__58.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSucem.Net.Http.HttpClient+\u003cFinishSendAsync\u003ed__58.MoveNext() at SystetHelpers.MSIResourcesAccessInfoHelper+\u003cGetResourcesAccessInfo\u003ed__0.MoveNext()\n.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\n at System.Runtime.m[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c56193ompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.ThreC.Main(System.String[])
在代码方面,我只是在开火
await httpClient.GetAsync($"http://xyz.eastus.cloudapp.azure.com/api/controller/{id}");
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsAsync<ResourceAccessInfo>();
该行为非常随机,10 次尝试中只会发生 2-3 次 我在第一次尝试时也应用了重试,然后尝试第二次但仍然失败
同样适用于 VM 容器。
已更新:
额外的异常信息: System.Net.Http.HttpRequestException: 发送请求时出错。 ---\u003e System.Net.WebException: 无法解析远程名称:\u0027cloudbridge1.eastus.cloudapp.azure.com\u0027\r\n 在 System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)\r\n 在 System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)\r\n --- 内部异常堆栈跟踪结束 ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task )\r\n at System.Net.Http.HttpClient.\u003cFinishSendAsync\u003ed__58.MoveNext()\r\n--- 从先前抛出异常的位置开始的堆栈跟踪结束 ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\r\n 在 UcClearly.MSIAPIHelpers.MSIResourcesAccessInfoHelper.\u003cGetResourcesAccessInfo\u003ed__0.MoveNext()
这表明远程服务器 DNS 未解析,我尝试使用服务器的 public IP,但随机行为相同,我不确定为什么 Azure 容器实例以这种随机方式表现
此行为是预期的。
Windows containers slow network readiness
On initial creation, Windows containers may have no inbound or outbound connectivity for up to 30 seconds (or longer, in rare cases). If your container application needs an Internet connection, add delay and retry logic to allow 30 seconds to establish Internet connectivity. After initial setup, container networking should resume appropriately.