简体   繁体   English

Azure Blob 存储 .NET 客户端请求超时

[英]Azure Blob Storage .NET client request timeout

I'm trying to understand the behavior of handling network errors in the Azure Storage .NET client.我试图了解在 Azure Storage .NET 客户端中处理网络错误的行为。 In short, my issue is:简而言之,我的问题是:

If I pull my network cable while I'm downloading a blob from blob storage, my application will hang for at least 30 minutes (this is how long my patience lasted - it probably hangs longer).如果我在从 blob 存储下载 blob 时拔掉网线,我的应用程序将挂起至少 30 分钟(这是我的耐心持续的时间——它可能挂得更久)。

For example, this happens if I use the following code (I have not configured any settings on the blob client itself).例如,如果我使用以下代码(我没有在 blob 客户端本身上配置任何设置),就会发生这种情况。

...

var blockBlob = container.GetBlockBlobReference("myblob.data");

var blobRequestOptions = new BlobRequestOptions()
    {
        RetryPolicy = new NoRetry(),
    };

using (var stream = new MemoryStream())
{
    blockBlob.DownloadToStream(stream, null, blobRequestOptions);
}

I know that I can configure the MaximumExecutionTime property in BlobRequestOptions, but it seems a bit strange to me that the default behavior is to hang indefinitely if there's a drop in network connectivity.我知道我可以在BlobRequestOptions中配置MaximumExecutionTime属性,但对我来说,默认行为是在网络连接下降时无限期挂起似乎有点奇怪。 This makes me suspect that I'm missing something basic on how the client is supposed to be used.这让我怀疑我错过了一些关于如何使用客户端的基本知识。 (There default value for MaximumExecutionTimeout appears to be Infinite). (MaximumExecutionTimeout 的默认值似乎是 Infinite)。

I also know I can pass in a ServerTimeout, but my understanding is that this is used internally in the Azure Storage service and would't be applicable if there's a network drop.我也知道我可以传入 ServerTimeout,但我的理解是,这是在 Azure 存储服务内部使用的,如果出现网络中断则不适用。

What I think I'm looking for specifically is a per-request timeout for the HTTP calls made to blob storage.我想我要特别寻找的是对 blob 存储进行的 HTTP 调用的每个请求超时。 Something like Timeout on a HttpWebRequest.类似于 HttpWebRequest 上的超时。

(I've reproduced my issue in the Azure Storage Client version 9.3.2) (我在 Azure 存储客户端版本 9.3.2 中重现了我的问题)

From my understanding of the SDK, the timeout is handled by default on the server side.根据我对SDK的理解,超时是在服务器端默认处理的。 I did not find anything regarding this on the MSDN, but the Azure Java SDK (using the same HTTP endpoints) says :我在 MSDN 上没有找到任何关于此的信息,但 Azure Java SDK(使用相同的 HTTP 端点)说:

The default maximum execution is set in the client and is by default null, indicating no maximum time.默认最大执行时间在客户端设置,默认为空,表示没有最大时间。

You can check it here : https://azure.github.io/azure-storage-java/index.html?com/microsoft/azure/storage/RequestOptions.html你可以在这里查看: https : //azure.github.io/azure-storage-java/index.html?com/microsoft/azure/storage/RequestOptions.html

Look for the setMaximumExecutionTimeInMs method.查找 setMaximumExecutionTimeInMs 方法。

Since the timeouts seem to be handled by the server and the default client has not default timeout value, it makes sense that you request never end when you unplug the router because you won't be able to catch the server-sided timeout.由于超时似乎由服务器处理并且默认客户端没有默认超时值,因此在拔下路由器时请求永远不会结束是有道理的,因为您将无法捕获服务器端超时。

I found that the storage sdk team had indeed acknowledged and addressed this bug in v8.1.3 as seen in the change log: https://github.com/Azure/azure-storage-net/blob/dfc88329b56ef022e38f2d39d709ddc2b41fe6a0/Common/changelog.txt我发现存储 sdk 团队确实承认并解决了 v8.1.3 中的这个错误,如更改日志所示: https : //github.com/Azure/azure-storage-net/blob/dfc88329b56ef022e38f2d39d709ddc2b41fe6a0/Common/changelog。

Changes in 8.1.3 :
- Blobs (Desktop) : Fixed a bug where the MaximumExecutionTime was not honored, leading to infinite wait, if due to a failure, e.g., a network failure after receiving the response headers, server stopped sending partial response.

commit: https://github.com/Azure/azure-storage-net/pull/459/commits/ad8fd6ad3cdfad77cfe23afe16f1f96c04ad90ee提交: https : //github.com/Azure/azure-storage-net/pull/459/commits/ad8fd6ad3cdfad77cfe23afe16f1f96c04ad90ee

However, your claim is you can reproduce this in 9.3.2.但是,您声称您可以在 9.3.2 中重现这一点。 I too, am seeing this issue with 11.1.1.我也是,在 11.1.1 中看到了这个问题。 I'm thinking that the bug was not fully addressed.我认为该错误尚未完全解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM