我使用以下内容将超时设置为1
秒:
DocumentClient documentClient = new DocumentClient(new Uri(DocumentDbEndpointUrl),
DocumentDbKey,
new ConnectionPolicy {
ConnectionMode = ConnectionMode.Gateway,
ConnectionProtocol = Protocol.Tcp,
RequestTimeout = new TimeSpan(0, 0, 0, 1) });
然后阅读:
return await documentClient.ReadDocumentAsync<Response>(docUri,
new RequestOptions { PartitionKey = new PartitionKey(key)});
但它并不尊重我设置的超时值,有时超时&gt; 5
秒。
答案 0 :(得分:1)
尝试使用类似的东西,
var connectionPolicy = new ConnectionPolicy
{
ConnectionMode = ConnectionMode.Direct,
ConnectionProtocol = Protocol.Tcp,
RequestTimeout = new TimeSpan(1, 0, 0),
MaxConnectionLimit = 1000,
RetryOptions = new RetryOptions
{
MaxRetryAttemptsOnThrottledRequests = 10,
MaxRetryWaitTimeInSeconds = 60
}
};
_client = new DocumentClient(new Uri(_uri), _key, connectionPolicy);