CloudTableClient 客户端超时

CloudTableClient client side timeout

使用 CloudTableClient 时,是否可以指定 客户端 端超时?

TableRequestOptions RetryPolicy 和 ServerTimeout 控制重试次数、尝试之间的延迟和存储服务端超时,但似乎没有涵盖客户端每次尝试超时(如 HttpClient.Timeout 属性).

我对依赖 ServerSideTimeout 的担忧是连接到实际服务器的延迟。

When using a CloudTableClient, is there a way to specify a client side timeout?

TableRequestOptions 的 MaximumExecutionTime 属性 可以帮助我们指定请求的所有潜在重试的最大执行时间,包括客户端和服务器端使用的时间。

tableClient.DefaultRequestOptions.MaximumExecutionTime = new TimeSpan(0, 0, 0, 0, 100);

如果在指定时间内无法处理请求,将抛出异常。

Microsoft.WindowsAzure.Storage.StorageException: 'The client could not finish the operation within specified timeout.'

like the HttpClient.Timeout property

HttpClient 的 Timeout 属性 也指定了响应返回之前的所有执行时间。

I'm hoping to find a per-retry timeout.

我建议您使用 MaximumExecutionTime。如果您需要客户端 DNS 解析超时,您可以获取或设置 ServicePointManager 的 DnsRefreshTimeout 属性。

ServicePointManager.DnsRefreshTimeout = 4*60*1000; // 4 minutes