我要删除批量商品,并在本地计算机上出现以下错误。我正在使用CosmosDB SDK 3.0。
尝试初始化CosmosBb时发生错误。一个或多个错误 发生了。 (响应状态代码不表示成功: 服务不可用(503);子状态:0; ActivityId: befe13e5-172f-4930-953f-e24bf9b0a14a;原因:(目前正在提供服务 不可用。 ActivityId:befe13e5-172f-4930-953f-e24bf9b0a14a, RequestStartTime:2020-08-06T07:04:58.1807989Z,RequestEndTime: 2020-08-06T07:05:28.2986219Z,尝试的区域数:1 响应时间:2020-08-06T07:04:59.1993537Z,StoreResult: StorePhysicalAddress: rntbd://127.0.0.1:10253 / apps / DocDbApp / services / DocDbServer18 / partitions / a4cb495e-38c8-11e6-8106-8cdcd42c33be / replicas / 1p /, LSN:-1,GlobalCommittedLsn:-1,PartitionKeyRangeId:IsValid: False,StatusCode:410,SubStatusCode:0,RequestCharge:0,ItemLSN: -1,SessionToken:,UsingLocalLSN:True,TransportException:发生客户端传输错误:无法连接到远程端点。 (时间:2020-08-06T07:04:59.1993537Z,活动ID: befe13e5-172f-4930-953f-e24bf9b0a14a,错误代码:ConnectFailed [0x0005],基本错误:套接字错误
这是我的删除方法。
private async Task DeleteAllExistingSubscriptions(string userUUId)
{
var subscriptions = await _repository
.GetItemsAsync(x => x.DistributionUserIds.Contains(userUUId), o => o.PayerNumber);
if (subscriptions.Any())
{
List<Task> bulkOperations = new List<Task>();
foreach (var subscription in subscriptions)
{
bulkOperations.Add(_repository
.DeleteItemAsync(subscription.Id.ToString(), subscription.PayerNumber));
}
await Task.WhenAll(bulkOperations);
}
}
Cosmos客户:
private static void RegisterCosmosClient(IServiceCollection serviceCollection, IConfiguration configuration)
{
string cosmosDbEndpoint = configuration["CosmoDbEndpoint"];
Ensure.ConditionIsMet(cosmosDbEndpoint.IsNotNullOrEmpty(),
() => new InvalidOperationException("Unable to locate configured CosmosDB endpoint"));
var cosmosDbAuthKey = configuration["CosmoDbAuthkey"];
Ensure.ConditionIsMet(cosmosDbAuthKey.IsNotNullOrEmpty(),
() => new InvalidOperationException("Unable to locate configured CosmosDB auth key"));
serviceCollection.AddSingleton(s => new CosmosClient(cosmosDbEndpoint, cosmosDbAuthKey,
new CosmosClientOptions { AllowBulkExecution = true }));
}
答案 0 :(得分:1)
该错误是客户端连接问题:
TransportException: A client transport error occurred: Failed to connect to the remote endpoint.
(Time: 2020-08-06T07:04:59.1993537Z,
activity ID: befe13e5-172f-4930-953f-e24bf9b0a14a,
error code: ConnectFailed [0x0005], base error: socket error
常见原因是资源匮乏: