首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ocelot网关只设置TimeOut值抛出错误

Ocelot网关只设置TimeOut值抛出错误
EN

Stack Overflow用户
提问于 2020-07-17 19:25:58
回答 1查看 3.9K关注 0票数 3

根据Ocelot文档服务质量,我们只能在路线上使用TimeOutValue,例如

代码语言:javascript
复制
"QoSOptions": {
    "TimeoutValue":5000
}

但这是抛出异常

代码语言:javascript
复制
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 

我的路线配置是

代码语言:javascript
复制
{
  "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核心版本是3.1,而八进制版本是16.0.1

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-29 21:22:30

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

我必须添加电路中断设置才能使此工作:

代码语言:javascript
复制
 "QoSOptions": {
    "ExceptionsAllowedBeforeBreaking":99999,
    "DurationOfBreak":0,
    "TimeoutValue":5000
  }
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62960586

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档