-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AddDockerfile: Fix Connectivity Issue: Cannot Assign Requested Address for #7210
Comments
Your web front end is trying to call your python container, but it's using localhost to talk to the python container? Why are you using localhost instead of http://secedgarwsapp? |
I tried but couldn't be found. How you will do it? |
Change this code: var secedgarwsapp = builder.AddDockerfile("secedgarwsapp", "./sec-edgar-ws")
//.WithHttpEndpoint(targetPort: 8000, env: "PORT") // Expose HTTP endpoint based on PORT environment variable
.WithHttpEndpoint(targetPort: 8000, port: 8000, name: "secedgarwsapp-http") // Bind host port 8000 to container port 8000
.WithExternalHttpEndpoints() // Make it accessible externally
.WithOtlpExporter(); // Enable OpenTelemetry for observability
builder.AddProject<Projects.aitrailblazer_Web>("webfrontend")
.WithExternalHttpEndpoints()
.WithReference(apiService)
.WithReference(secedgarwsapp.GetEndpoint("secedgarwsapp-http"))
.WaitFor(secedgarwsapp); Then it should work. PS: The documentation explains the pattern https://learn.microsoft.com/en-us/dotnet/aspire/fundamentals/app-host-overview?tabs=docker#connection-string-and-endpoint-references |
in my.Web:
calling it:
|
Remove the port |
|
Sorry, I meant: var secedgarwsapp = builder.AddDockerfile("secedgarwsapp", "./sec-edgar-ws")
.WithHttpEndpoint(targetPort: 8000, port: 8000) // Bind host port 8000 to container port 8000
.WithExternalHttpEndpoints() // Make it accessible externally
.WithOtlpExporter(); builder.Services.AddHttpClient<SECEdgarWSAppService>(client =>
{
client.BaseAddress = new("http://secedgarwsapp");
client.Timeout = TimeSpan.FromMinutes(5); // Total timeout for all retries combined
}) Change both of the following. |
|
Is your application using service discovery? Are service defaults added to the project? |
yes:
my.ServiceDefaults is not changed. it was generated when I created the project. |
There should be a call in your application to AddServiceDefaults, that's the logic that wires up service discovery. |
|
This solution is working: my.AppHost
my.Web
|
Excellent! |
Is there an existing issue for this?
Describe the bug
Problem Description
Error in Connectivity
The application attempts to connect to
localhost:8000
but fails with the error:Cannot assign requested address
This issue stems from the inability of the
SECEdgarWSAppService
to reach the expected container's HTTP endpoint.Retry Attempts
Logs
webfrontend
.TSLA
.Components Overview
Docker Setup
A Docker container (
secedgarwsapp
) runs a Python app to handle SEC filings. Key features:Uvicorn
to expose the app on port8000
.localhost
as the defaultBASE_ADDRESS
.Dockerfile Highlights
8000
.Uvicorn
to servemain:app
.Service Configuration in
my.Web
HttpClient
http://localhost:8000
.Program.cs in
my.AppHost
The
secedgarwsapp
service:8000
both internally and externally.webfrontend
project.GetCIKAsync
MethodThis method:
GET
request to fetch the CIK for a given ticker.my.AppHost/Program.cs
my.AppHost/Dockerfile
my.Web
Program.cs
SECEdgarWSAppService.cs
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version info
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: