Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Azure Blob存储.Net客户端库和TCP连接随时间变化_C#_.net_Sockets_Azure_Azure Storage Blobs - Fatal编程技术网

C# Azure Blob存储.Net客户端库和TCP连接随时间变化

C# Azure Blob存储.Net客户端库和TCP连接随时间变化,c#,.net,sockets,azure,azure-storage-blobs,C#,.net,Sockets,Azure,Azure Storage Blobs,我们正在使用Azure blob存储来存储来自数据馈送的传入消息,我们每天收到大约1.5GB的数据,然后通过消息队列rabbitmq对其进行处理。以下是安装程序的外观: 生产者->在Azure blob中存储XML文件->将blob地址发布到队列 消费者->从队列读取blob地址->在内存中下载blob 下面是为每条消息执行的下载blob方法: private string GetBlobText(string containerName, string blobName) { // P

我们正在使用Azure blob存储来存储来自数据馈送的传入消息,我们每天收到大约1.5GB的数据,然后通过消息队列rabbitmq对其进行处理。以下是安装程序的外观:

生产者->在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,但这对我们没有帮助。我们应该进一步研究什么来解决这个问题

Microsoft.WindowsAzure.Storage.StorageException:无法连接到远程服务器-->System.Net.WebException:无法连接到远程服务器-->System.Net.Sockets.SocketException:无法对套接字执行操作,因为系统缺少足够的缓冲区空间或队列已满40.68.232.24:443blob.am5prdstr02a.store.core.windows.net

据我了解,可能是TCP/IP端口耗尽。我假设您可以使用Netstat来查询网络连接的状态和正在使用的端口。有关更多详细信息,您可以参考以了解解释和诊断此问题的方法


如果端口耗尽发生在客户端计算机中,我假设您可以增加客户端TCP/IP套接字连接的临时端口的上限范围,并减少客户端TCP/IP套接字连接超时,有关更多详细信息,请参阅。此外,您还可以将客户端应用程序扩展到不同计算机之间的多个实例。

通过拆分不同计算机上的实例进行扩展肯定会有所帮助。但我们面临的问题是,在这段时间内,TCP连接加上等待时间会耗尽端口。