You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
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
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
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.
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.The above works fine, I get my service exposed to port 9000, internally running on
targetPort
.However, the Aspire host console continues complaining about:
Expected Behavior
The log error should not be there.
Steps To Reproduce
Exceptions (if any)
No response
.NET Version info
net9, aspire sdk 9
Anything else?
No response
The text was updated successfully, but these errors were encountered: