-
|
The following error only happens in version > 23.0.0; Before upgrading from 23.0.0 everything was working fine. Nothing else changed in the code or configuration. I've got Consul running in a Docker container: Consul:
image: hashicorp/consul
container_name: consul
ports:
- "8500:8500"
- "8600:8600/udp"
command: >
consul agent -server -bootstrap-expect=1 -ui -node=consul-server
-client=0.0.0.0 -bind=0.0.0.0 -data-dir=/consul/data
volumes:
- ./data/consul:/consul/data
networks:
- myNetworkAnd in the same Docker network I've got my API gateway using Ocelot and Ocelot.Provider.Consul. This is my {
"Routes":
[
{
"UpstreamHeaderTransform":
{
"SkipTenantTokenMiddleware": "true"
},
"UpstreamPathTemplate": "/api/accounts/health",
"DownstreamPathTemplate": "/health",
"DownstreamScheme": "http",
"ServiceName": "accounts-api",
"LoadBalancerOptions":
{
"Type": "RoundRobin"
},
"UseServiceDiscovery": true
}
],
"GlobalConfiguration":
{
"RequestIdKey": "OcelotRequestId",
"ServiceDiscoveryProvider":
{
"Type": "Consul",
"Host": "consul",
"Port": 8500,
"Scheme": "http",
"ConfigurationKey": "InternalConfiguration"
}
}
}The problem is in versions > 23.0.0, when I make any HTTP request to my Basically the downstream url is pointing to the Consul node ("consul-server") instead of the actual service url ("accounts-api"). For reference these are the logs before upgrading from 23.0.0: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
|
Dragos,
The "problem" is something the Ocelot community is already aware of 😉
All questions related to Consul discovery are available here: Consul Q&A
The Consul Service Builder feature was introduced in version 23.3.0. Check the footnote about the feature. |
Beta Was this translation helpful? Give feedback.
-
Alright! What is the hostname of the Consul container in docker network inspect myNetwork -f '{{ range $id, $container := .Containers }}{{ printf "%s: %s\n" $id $container.Name }}{{ end }}'It will display something like this: In your Docker configuration,
To resolve the issue in your Docker+Consul+Ocelot setup and Docker network, you can try these approaches:
Hope it helps! |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your feedback, and I just want to reiterate that everything was working fine until I upgraded from 23.0.0 to 24.0.0. Nothing else has changed in the code or configuration. After the upgrade I started noticing the behavior I have described above. |
Beta Was this translation helpful? Give feedback.
Alright! What is the hostname of the Consul container in
myNetwork? You can check all hosts in the Docker network using the bash command:docker network inspect myNetwork -f '{{ range $id, $container := .Co…