- Notifications
You must be signed in to change notification settings - Fork744
-
Hi, I’ve already set up the microservices project and am now trying to adopt .NET Aspire. However, the issue is that we are using HttpClientFactory.Create() for dynamic facade service calling. This works well in a Docker Compose environment, but Aspire encourages defining a specific HttpClient for each service, which feels less dynamic and requires more effort. What would be the better approach in this case? |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment 1 reply
-
What is |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Thanks for your response! varurl=configuration.GetValue<string>($"ServiceApiLocations:{serviceName}");if(string.IsNullOrEmpty(url)){thrownewArgumentException($"ServiceApiLocations:{serviceName} is null or empty");}varclient=newApiClient(httpClientFactory,serviceProvider.GetRequiredService<ILogger<ApiClient>>(),serviceProvider.GetRequiredService<IHostEnvironment>(),newUri(url),jsonSerializerSettings);// httpClientFactory is injected via constructorreturnclient;//Inside api clientpublicApiClient(IHttpClientFactory httpClientFactory,ILogger logger,IHostEnvironment hostEnvironment,Uri baseAddress,JsonSerializerSettings? jsonSerializerSettings=null){this.httpClient=httpClientFactory.CreateClient("httpClient");this.httpClient.BaseAddress=baseAddress;this.jsonSerializerSettings=jsonSerializerSettings??newJsonSerializerSettings();this.logger=logger;} When send the request it's thrown an exception: "no such host is known" |
BetaWas this translation helpful?Give feedback.