gpt4 book ai didi

asp.net-core - Ocelot API网关设置只超时值抛出错误

转载 作者:行者123 更新时间:2023-12-05 05:00:48 30 4
gpt4 key购买 nike

根据 Ocelot 文档 Quality Of Service我们只能在路由中提及 TimeOutValue,比如

"QoSOptions": {
"TimeoutValue":5000
}

但这是抛出异常

Ocelot.Requester.Middleware.HttpRequesterMiddleware: Debug: requestId: 800002b3-0002-fd00-b63f-84710c7967bb, previousRequestId: no previous request id, message: IHttpRequester returned an error, setting pipeline error
Ocelot.Responder.Middleware.ResponderMiddleware: Warning: requestId: 800002b3-0002-fd00-b63f-84710c7967bb, previousRequestId: no previous request id, message: Error Code: UnableToCompleteRequestError Message: Error making http request, exception: System.ArgumentException: The enumerable of policies to form the wrap must contain at least two policies. (Parameter 'policies')
at Polly.Policy.WrapAsync(IAsyncPolicy[] policies)
at Ocelot.Provider.Polly.PollyCircuitBreakingDelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Ocelot.Requester.HttpClientHttpRequester.GetResponse(HttpContext httpContext) errors found in ResponderMiddleware. Setting error response for request path:/api/v1/cust/clients, request method: GET
Ocelot.Errors.Middleware.ExceptionHandlerMiddleware: Debug: requestId: 800002b3-0002-fd00-b63f-84710c7967bb, previousRequestId: no previous request id, message: ocelot pipeline finished
Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request finished in 200.2779ms 500

我的路由配置是

{
"Routes": [
{
"DownstreamPathTemplate": "/api/{version}/cust/{everything}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5001
}
],
"UpstreamPathTemplate": "/api/{version}/cust/{everything}",
"UpstreamHttpMethod": [],
"QoSOptions": {
"TimeoutValue": 900000
}
}
],
"GlobalConfiguration": {
"RequestIdKey": "OcRequestId",
"AdministrationPath": "/administration"
}
}

我的.Net Core版本是3.1,Ocelet版本是16.0.1

最佳答案

也许只有一个策略(超时策略)会带来一些问题。

我必须添加熔断设置才能使其正常工作:

 "QoSOptions": {
"ExceptionsAllowedBeforeBreaking":99999,
"DurationOfBreak":0,
"TimeoutValue":5000
}

关于asp.net-core - Ocelot API网关设置只超时值抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62960586/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com