Score:0

why consul discovery return https on localhost but on server just return http?

tl flag

I tested two scenarios by hashicorp consul

1.I implemented service discovery by hashicorp consul on .net7 , but when i want get service address from consul , it just return http of that service not https. I registered my services by registrator on docker and discover servicces by .net dockerized too.

2.but i test this scenario on my localhost i implemented two apis on localhost and registered one of them on consul that was running on docker server I've seen that when i discover api1 from api2 through consul , I requested https of api1 but consul switch and change it to http and it works and i get result of that. but the same situation on my server(scenario1) doesnt work

my implementation:

services.AddServiceDiscovery(options => options.UseConsul());

//HttpClinetFactory services.AddHttpClient("DiscoveryRandom").ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { ServerCertificateCustomValidationCallback = (sender, cert, chain,sslPolicyErrors) => true, }).AddHttpMessageHandler().AddServiceDiscovery();

// I inject : IHttpClientFactory clientFactory

_httpClient = clientFactory.CreateClient("DiscoveryRandom");

_httpClient.BaseAddress = new Uri($"https://{ServiceName on consul}");

// my appsetting for scenario 1 that register done by docker on server and i just doscovered it through consul:

"$schema": "https://steeltoe.io/schema/latest/schema.json", "Consul": { "Host": "10.200.8.178", "Discovery": { "Register": false } }

// my appsetting for scenario 2 that register done by myself on localhost:

// setting for api1 to register on consul

"$schema": "https://steeltoe.io/schema/latest/schema.json", "Consul": { "Host": "10.200.8.178", "Discovery": { "Register": true, "serviceName": "TestConsul", "hostName": "localhost", "port": 7141, "deregister": false } }

// and setting for service discovery api2

"$schema": "https://steeltoe.io/schema/latest/schema.json", "Consul": { "Host": "10.200.8.178", "Discovery": { "Register": false } }

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.