Replies: 5 comments 1 reply
-
It seems you try get Endpoint url before host started, endpoint allocated when host completly started. |
Beta Was this translation helpful? Give feedback.
-
Thanks for help.
Not sure about that. OK. I am not Aspire expert, but I remember I tried a lot of variants. Have you tried to repro? It is quite simple. OK. Trying. Changed var a = builder.Build();
Console.WriteLine($"IP {apiService.GetEndpoint("http").Url}");
Console.WriteLine($"IP {apiService.GetEndpoint("https").Url}");
a.Run(); The same result. I think placing code after There are several comments in eShop repo (issue I linked) |
Beta Was this translation helpful? Give feedback.
-
Endpoint allocated after |
Beta Was this translation helpful? Give feedback.
-
Confirmed (tested): Code: var a = builder.Build();
a.Run();
Console.WriteLine($"IP {apiService.GetEndpoint("http").Url}");
Console.WriteLine($"IP {apiService.GetEndpoint("https").Url}"); Does not throw, but cannot be used.
Nope. Info about IP address is needed eariler. |
Beta Was this translation helpful? Give feedback.
-
The eshop bug is for a different reason. It's because when you run on the command line, the http launch profile is selected and there's no https endpoint defined. The above is because you are resolving it too early. If you want to print the endpoint then you can resolve it after Starting: var builder = DistributedApplication.CreateBuilder(args);
var appA = builder.AddNpmApp("app-a", "../app-a")
.WithHttpEndpoint(env: "PORT")
.WithExternalHttpEndpoints()
.PublishAsDockerFile();
var httpEndpoint = appA.GetEndpoint("http");
var app = builder.Build();
app.Start();
Console.WriteLine($"URL: {httpEndpoint.Url}");
app.WaitForShutdown(); |
Beta Was this translation helpful? Give feedback.
-
Is there an existing issue for this?
Describe the bug
This is duplicate of issue reported in eShop,
dotnet/eShop#228
but it needs more love, so adding it here.
It is on Mac, but I think it is irrelevant.
Calling
crashes with:
Expected Behavior
Should handle Exception at least.
Steps To Reproduce
Cleanup
Create minimal sample
Run:
Now add:
before:
Run again
and watch Der Untergang:
Exceptions (if any)
.NET Version info
Anything else?
dotnet
)Beta Was this translation helpful? Give feedback.
All reactions