System.Net.Http.HttpRequestException从Azure Datalake V2下载多个文件
我正在从Azure Datalake V2下载大量大于1000的文件,并且不断出现异常:System.Net.Http.HttpRequestException从Azure Datalake V2下载多个文件,azure,.net-core,azure-data-lake,Azure,.net Core,Azure Data Lake,我正在从Azure Datalake V2下载大量大于1000的文件,并且不断出现异常: The SSL connection could not be established, see inner exception. <--- Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.. <--- An exi
The SSL connection could not be established, see inner exception.
<--- Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..
<--- An existing connection was forcibly closed by the remote host.
守则:
var downloadTasks = job.Files.AsParallel().Select(x => Download(x));
await Task.WhenAll(downloadTasks);
private async Task Download(DownloadableFile file)
{
try
{
var options = new BlobRequestOptions
{
ParallelOperationThreadCount = 8,
DisableContentMD5Validation = true,
StoreBlobContentMD5 = false
};
var xzBlob = await _cloudBlobFileService.GetBlockBlobReference(file.FilePath);
await xzBlob.DownloadToFileAsync(file.LocalFilePath, FileMode.Create, null, options, null);
}
catch (Exception e)
{
_log.LogCritical(e, "Error downloading " + file.FilePath);
}
}
我还补充说:
ServicePointManager.DefaultConnectionLimit = Environment.ProcessorCount * 8;
ServicePointManager.Expect100Continue = false;
使用.Net core 3.1和WindowsAzure.Storage 9.3.3
在webjob中编程.cs main方法的步骤
我们曾经在没有datalake的情况下配置blobstorage,但在切换到datalake之后,出现了这种情况。它不会影响应用程序,因为跳过的下载会在以后重试。不过,如果能知道是什么原因造成的,那就太好了 你可以在11月份开始尝试流行的GA,尽管我不能保证它能解决这个问题。这完全是重写 虽然无法仅从错误消息中精确定位,但有几点需要注意:
ParallelOperationThreadCount
是for,因此在本例中它不会限制请求。缺省限制,建议在使用.NETCARE时,需要考虑。如果同时访问同一个blob或分区的次数过多,则可能会开始撞到存储中的内存感谢您的回答,我将研究存储SDK。我已经添加了一个编辑,因为我已经通过问题中添加的代码增加了连接限制。
ServicePointManager.DefaultConnectionLimit = Environment.ProcessorCount * 8;
ServicePointManager.Expect100Continue = false;