当我们的Azure Web角色收到许多HTTP请求时,有时会遇到SocketException。异常表明无法连接到某些下游服务器,但它们并非全部来自同一服务器,实际上它们来自属于不同Azure服务的不同服务器IP,尤其是Azure Key Vault和Azure搜索,因此这非常重要问题不太可能出在下游服务器上。在某些情况下,失败是由于Azure SQL发出的,因为请求不是HTTP协议,因此问题一定不在HTTP层中。我希望知道如何解决该问题,确认/证明这确实是我们的Web角色VM中的客户端问题,以及如何监视该问题即将发生。也许我们的网络角色用尽了并发TCP连接?也许它耗尽了网络吞吐量?也许我们没有可用的线程来拾取打开的连接?我们可以基于Windows性能计数器监视所有这些事情,我想知道还有什么可以解释这种连接问题的。
异常ToString()开头:
Exception = System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond |Hidden-IP|:443
at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at Microsoft.Rest.RetryDelegatingHandler.<SendAsync>d__15.MoveNext()