Skip to content
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

Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]: could not start the proxy {"ServiceName": {"name":"core-api"}, "Reconciliation": 21, "error": "could not start the proxy for the service: listen tcp 127.0.0.1:9000: bind: address already in use"} #6995

Open
1 of 2 tasks
tmarkovski opened this issue Dec 29, 2024 · 0 comments

Comments

@tmarkovski
Copy link

tmarkovski commented Dec 29, 2024

Is there an existing issue for this?

  • I have searched the existing issues
  • There are older issue where this was a breaking bug, in my case it's not breaking

Describe the bug

This is an error reported to the console, but the Aspire host and the services run and operate correctly as intended. Here's my setup.

var coreService = builder.AddProject<Projects.Server>("core-api")
    .WithHttpEndpoint(env: "PORT", port: 9000)
    .WithExternalHttpEndpoints();

In the above, I'm instructing Aspire to set the PORT variable to whatever internal port it will assign, but expose the endpoint to the specific port.

In my service, I simply bind to the PORT env variable.

if (int.TryParse(Environment.GetEnvironmentVariable("PORT") ?? "8080", out var port) && port is < 1 or > 65535)
{
    throw new Exception("PORT must be a valid integer between 1 and 65535");
}
builder.WebHost.UseKestrel(options =>
{
    options.ListenAnyIP(port, listenOptions =>
    {
        listenOptions.Protocols = HttpProtocols.Http1AndHttp2;
    });
});

The above works fine, I get my service exposed to port 9000, internally running on targetPort.
Image

However, the Aspire host console continues complaining about:

fail: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      could not start the proxy {"ServiceName": {"name":"core-api"}, "Reconciliation": 21, "error": "could not start the proxy for the service: listen tcp 127.0.0.1:9000: bind: address already in use"}

Expected Behavior

The log error should not be there.

Steps To Reproduce

  • Create new Aspire host
  • Add .NET Core service
  • Configure as shown in the bug description

Exceptions (if any)

No response

.NET Version info

net9, aspire sdk 9

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant