c# - Ocelot Consul - 错误租赁负载均衡器
问题描述
我正在使用 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
我有什么配置错误吗?
解决方案
我在 Consul 地址字段中使用http://localhost向 Consul 注册了我的服务。我删除了 uri.Scheme 并将 DownstreamScheme 添加到我的 ocelot 配置文件中,一切正常。
感谢 @TomPallister 在Ocelot的 github 存储库中提供的帮助。
推荐阅读
- javascript - 在javascript中同时播放多个声音
- python-3.x - 将数组数组展平为数组向量
- node.js - Twilio:如何通过 API 获取程序化聊天统计信息?
- c++ - 0xC0000005:访问冲突写入位置 0xCDCCDCD 动态分配错误
- google-apps-script - 使用 parseCsv 生成的 csv 文件是否存储在某处?
- python - 使用 boost python 元组,如何循环元组项?
- html - 我的目标是在悬停时将图标替换为文本。我遇到的问题是当图标悬停时所有图标都向左移动
- windows - Powershell将文件从映射驱动器“Z:”复制到用户本地“C:”
- c# - 如何处理 SSL/TLS 证书错误在 HttpClient 上不断发生的情况,即使我覆盖了委托?
- string - 随机字符串选择器(字符串名称完全相同,除了数字)