使用 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 解析超时,您可以获取或设置 DnsRefreshTimeout ServicePointManager 的属性。
ServicePointManager.DnsRefreshTimeout = 4*60*1000; // 4 minutes
关于c# - CloudTableClient客户端超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44318005/