Azure cosmosdb 如何设置ReadDocumentSync(Azure Cosmos Db)的超时

Azure cosmosdb 如何设置ReadDocumentSync(Azure Cosmos Db)的超时,azure-cosmosdb,Azure Cosmosdb,我使用以下方法将超时设置为1秒: DocumentClient documentClient = new DocumentClient(new Uri(DocumentDbEndpointUrl), DocumentDbKey, new ConnectionPolicy { ConnectionMode = ConnectionMode.Gateway, ConnectionProtocol = Protocol.Tcp, RequestTim

我使用以下方法将超时设置为
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)});
return wait documentClient.readdocumentsync(docUri,
新请求选项{PartitionKey=new PartitionKey(key)});

但它不尊重我设置的超时值,有时超时时间为>
5
秒。

试试这样的方法

        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);

对不起,这有什么意义?此时间跨度表示超时1小时。我遗漏了什么吗?它可以配置,但这并不能真正回答他关于为什么会有问题的问题,对吗?基本上所有的答案都是“将ConnectionMode从网关更改为直接”