首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ocelot Consul -租借负载均衡器时出错

Ocelot Consul -租借负载均衡器时出错
EN

Stack Overflow用户
提问于 2018-09-12 23:46:30
回答 1查看 1.1K关注 0票数 0

我使用的是Ocelot和Ocelot.Provider.Consul的11.0.2版本。下面是我的ocelot.json文件。

代码语言:javascript
复制
{
  "ReRoutes": [
    {
      "DownstreamPathTemplate": "/v1/vaults",

      "ServiceName": "testservice",  
      //"LoadBalancer": "LeastConnection",
      //"LoadBalancerOptions": {
      //  "Type": "LeastConnection"
      //},
      "UpstreamPathTemplate": "/api/values",
      "UpstreamHttpMethod": [ "Get" ]
    }
  ],
  "GlobalConfiguration": {
    "RequestIdKey":  "OcelotRequestId", 
    "ServiceDiscoveryProvider": {
      "Host": "localhost",
      "Port": 8500,
      "Type": "Consul"
    }
  }
}

当我提交请求时,我会得到以下日志信息。

代码语言:javascript
复制
requestId: 8000001a-0004-ff00-b63f-84710c7967bb, previousRequestId: no previous request id, message: Unable to use service Address: http://localhost and Port: 56736 as it is invalid. Address must contain host only e.g. localhost and port must be greater than 0
dbug: Ocelot.LoadBalancer.Middleware.LoadBalancingMiddleware[0]
      requestId: 8000001a-0004-ff00-b63f-84710c7967bb, previousRequestId: no previous request id, message: there was an error leasing the loadbalancer, setting pipeline error
warndbug: Ocelot.LoadBalancer.Middleware.LoadBalancingMiddleware[0]
      requestId: 8000001a-0004-ff00-b63f-84710c7967bb, previousRequestId: no previous request id, message: There were no services in NoLoadBalancer
warn: Ocelot.Responder.Middleware.ResponderMiddleware[0]
      requestId: 8000001a-0004-ff00-b63f-84710c7967bb, previousRequestId: no previous request id, message: Error Code: ServicesAreEmptyError Message: There were no services in NoLoadBalancer errors found in ResponderMiddleware. Setting error response for request path:/api/values, request method: GET
dbugdbug: Ocelot.Errors.Middleware.ExceptionHandlerMiddleware[0]
      requestId: 8000001a-0004-ff00-b63f-84710c7967bb, previousRequestId: no previous request id, message: ocelot pipeline finished

我是否有配置错误的东西?

EN

回答 1

Stack Overflow用户

发布于 2018-09-13 22:43:51

我在Consul address字段中使用http://localhost注册了我的服务。我删除了uri.Scheme并将DownstreamScheme添加到我的ocelot配置文件中,一切都正常了。

感谢@TomPallister在Ocelot的github存储库中的帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52299053

复制
相关文章

相似问题

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