CloudTableClient客户端超时

时间:2017-06-01 22:22:25

标签: c# azure azure-storage azure-table-storage

使用CloudTableClient时,有没有办法指定客户端端超时?

TableRequestOptions RetryPolicy和ServerTimeout控制重试次数,尝试之间的延迟以及存储服务端超时,但似乎不包括客户端每次尝试超时(如HttpClient.Timeout属性)。

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

1 个答案:

答案 0 :(得分:2)

  

使用CloudTableClient时,有没有办法指定客户端超时?

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.'
  

类似于HttpClient.Timeout属性

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

  

我希望找到一次重试超时。

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

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