Ocelot Consul - Ошибка лизинга балансировки нагрузки - PullRequest
0 голосов
/ 12 сентября 2018

Я использую версии 11.0.2 Ocelot и Ocelot.Provider.Consul.Ниже приведен мой файл ocelot.json.

{
  "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"
    }
  }
}

Когда я отправляю запрос, я получаю следующую информацию журнала.

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

Неужели у меня что-то неправильно настроено?

1 Ответ

0 голосов
/ 13 сентября 2018

Моя служба была зарегистрирована в Консуле, используя http://localhost в поле адреса Консула.Я удалил uri.Scheme и добавил DownstreamScheme в мой файл конфигурации ocelot, и все работает.

Спасибо @TomPallister за помощь в репозитории github для Ocelot .

...