2017-09-27 64 views
0

我們使用Azure blob存儲來存儲來自數據饋送(我們每天接收大約1.5GB數據)的傳入消息,然後處理它們,這些消息是通過消息觸發的隊列(rabbitmq)。下面是設置的樣子:Azure Blob存儲.Net客戶端庫和TCP連接隨着時間的推移

生產者 - 在Azure中的BLOB>存儲XML文件 - >發佈BLOB地址排隊

消費 - >讀隊列中的BLOB地址 - >在內存中下載的blob

這裏是每個消息執行下載的blob方法:

private string GetBlobText(string containerName, string blobName) 
{ 
    // Parse the connection string and return a reference to the storage account. 
    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Settings.Default.DatafeedStorageConnString); 
    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); 
    CloudBlobContainer container = blobClient.GetContainerReference(containerName); 
    CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName); 
    return blockBlob.DownloadText(Encoding.UTF8); 
} 

這條管道是在一個相當頻繁的速度運行,因此我們看到,隨着時間的推移(幾個星期)的節目開始接收套接字錯誤。下面是跟蹤:

Microsoft.WindowsAzure.Storage.StorageException: Unable to connect to the remote server ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full 40.68.232.24:443 
    at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) 
    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.GetResponse() 
    at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 695 
    --- End of inner exception stack trace --- 
    at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 604 
    at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.DownloadRangeToStream(Stream target, Nullable`1 offset, Nullable`1 length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlob.cs:line 675 
    at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.DownloadToStream(Stream target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlob.cs:line 234 
    at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.DownloadText(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlockBlob.cs:line 1279 

這似乎像沒有有效地處理連接的問題,我們曾試圖重用blobClient,但是這並沒有幫助我們。我們還需要進一步解決這個問題呢?

回答

1

Microsoft.WindowsAzure.Storage.StorageException:無法連接到遠程服務器---> System.Net.WebException:無法連接到遠程服務器---> System.Net.Sockets.SocketException:不能因爲系統缺乏足夠的緩衝空間或執行套接字上的操作,因爲隊列已滿40.68.232.24:443(blob.am5prdstr02a.store.core.windows.net)

按我的理解,它可能是TCP/IP端口耗盡。我假設您可以使用Netstat來查詢您的網絡連接狀態和您正在使用的端口。有關更多詳細信息,請參閱here以獲取解釋和解決此問題的方法。

如果您的客戶端計算機發生端口耗盡,我認爲您可以增加用於客戶端TCP/IP套接字連接的短暫端口的上限範圍,並減少客戶端TCP/IP套接字連接超時,有關更多詳細信息,請參閱here。此外,您可以將客戶端應用程序擴展到不同計算機之間的多個實例。

+0

通過在不同計算機上拆分實例來擴展規模肯定會有所幫助。但是我們面臨的問題是,在此期間,與TIME_WAIT的TCP連接加起來耗盡了端口。 – maulik13