-
Notifications
You must be signed in to change notification settings - Fork 474
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 9 fails to stop projects #6704
Comments
Adding sample exceptions:
and
|
A coworker of mine has been getting similar issues. In that case they were running an ARM MacOS (not sure of the OS version right now) device and starting the app host using Upon stopping and starting the app host, all the C# projects were failing to start since the ports were already in use. |
### Summary & Motivation Aspire is now configured to keep SQL Server alive between debug sessions using the new Aspire 9 `.WithLifetime(ContainerLifetime.Persistent)`, significantly improving secondary startup. Unfortunately, Aspire does not seem to release ports immediately upon shutdown, requiring 10 seconds to a minute before the AppHost can restart. To mitigate this issue temporarily, logic has been added to kill any Developer Control Pane processes (`dcpctrl`) from previous sessions when starting the AppHost, preventing conflicts and strange errors. For more details, see this issue: dotnet/aspire#6704. The SPA generation and `index.html` caching strategy have been updated to align with the new Aspire startup behavior during debugging. The AppGateway no longer launches automatically when starting Aspire AppHost, as it needs a moment to be ready. Additionally, a bug has been resolved where the frontend incorrectly used the old `platformplatform.pfx` certificate instead of `localhost.pfx`. Lastly, a fix for a duplicated `dotnet dotnet` issue in the README has been applied. ### Checklist - [x] I have added a Label to the pull-request - [x] I have added tests, and done manual regression tests - [x] I have updated the documentation, if necessary
I have the same issue. It seems like the Developer Control Pane takes up to 1 minute to shut down. I made an ugly hack to find and kill any hanging control pane as the first step when starting the AppHost. See this commit: platformplatform/PlatformPlatform@1772f94 |
If you are impacted by this, it MAY help to edit your AppHost/Properties/launchSettings.json file between debugger runs to change the Dashboard port number between launches (I bump the port number up or down by 1 each time). This gives the Dashboard extra time to reset (others have reported the Dashboard is the worst/longest duration stuck port offender here). If you have multiple other projects also getting stuck, this unfortunately won't unblock the others. |
That’s what I see too. If I restart before the DCP process is ready, it sometimes takes more than a 1 minute to release the ports... but if you wait 10–15 seconds before starting, it almost always releases. In Aspire 8.2, this used to be 3-5 seconds, and in Aspire 8.0 this was not a problem at all. The code below works for me (only tested on macOS). The only problem is that the browser starts immediately, and the dashboard is not properly shown until I manually hit refresh. using System.Diagnostics;
using AppHost;
using Projects;
// Detect if Aspire ports from the previous run are released. See https://github.com/dotnet/aspire/issues/6704
EnsureDeveloperControlPaneIsNotRunning();
var builder = DistributedApplication.CreateBuilder(args);
// Aspire configuraiton here...
await builder.Build().RunAsync();
void EnsureDeveloperControlPaneIsNotRunning()
{
const string processName = "dcpctrl"; // The Aspire Developer Control Pane process name
var process = Process.GetProcesses()
.SingleOrDefault(p => p.ProcessName.Contains(processName, StringComparison.OrdinalIgnoreCase));
if (process == null) return;
Console.WriteLine($"Shutting down developer control pane from previous run. Process: {process.ProcessName} (ID: {process.Id})");
Thread.Sleep(TimeSpan.FromSeconds(5)); // Allow Docker containers to shut down to avoid orphaned containers
try
{
process.Kill();
Console.WriteLine($"Process {process.Id} killed successfully.");
}
catch (Exception ex)
{
Console.WriteLine($"Failed to kill process {process.Id}: {ex.Message}");
}
} |
Is there an existing issue for this?
Describe the bug
Aspire 9 seems to have lots of problems stopping projects.
In Aspire 8, I routinely started and stopped solutions without issue.
In Aspire 9 on OSX with Podman Desktop and the Rider Aspire plugin, about half the time there are stuck ports preventing Aspire projects from running correctly. I don't know about other operating systems.
All of this is somewhat anecdotal, as I don't have a repro that happens every time, I just know I commonly have the problem. That said, I think closing open browser tabs from the previous session may reduce the incidence of this issue (that was not required with Aspire 8).
Expected Behavior
Starting, stopping, and restarting Aspire projects should "just work", including regardless of whether there are browser tabs left open from a previous run.
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version info
IMPORTANT NOTE: I'm running via JetBrains Rider 2024.3 Build #RD-243.21565.191 on OSX, which I believe contains its own dotnet that doesn't show up using dotnet --info.
That said, here is my dotnet --info:
.NET SDK:
Version: 8.0.201
Commit: 4c2d78f037
Workload version: 8.0.200-manifests.2772ffde
Runtime Environment:
OS Name: Mac OS X
OS Version: 14.6
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/8.0.201/
.NET workloads installed:
[aspire]
Installation Source: SDK 8.0.200
Manifest Version: 8.2.1/8.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.aspire/8.2.1/WorkloadManifest.json
Install Type: FileBased
Host:
Version: 8.0.4
Architecture: arm64
Commit: 2d7eea2529
.NET SDKs installed:
6.0.401 [/usr/local/share/dotnet/sdk]
6.0.403 [/usr/local/share/dotnet/sdk]
6.0.404 [/usr/local/share/dotnet/sdk]
6.0.405 [/usr/local/share/dotnet/sdk]
6.0.407 [/usr/local/share/dotnet/sdk]
6.0.408 [/usr/local/share/dotnet/sdk]
6.0.410 [/usr/local/share/dotnet/sdk]
6.0.413 [/usr/local/share/dotnet/sdk]
6.0.415 [/usr/local/share/dotnet/sdk]
7.0.100 [/usr/local/share/dotnet/sdk]
7.0.101 [/usr/local/share/dotnet/sdk]
7.0.102 [/usr/local/share/dotnet/sdk]
7.0.202 [/usr/local/share/dotnet/sdk]
7.0.203 [/usr/local/share/dotnet/sdk]
7.0.304 [/usr/local/share/dotnet/sdk]
7.0.307 [/usr/local/share/dotnet/sdk]
7.0.410 [/usr/local/share/dotnet/sdk]
8.0.100 [/usr/local/share/dotnet/sdk]
8.0.201 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.15 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.16 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.18 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.21 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.23 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.11 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.12 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.16 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.18 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.21 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.23 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
x64 [/usr/local/share/dotnet/x64]
Environment variables:
Not set
global.json file:
/Users/........./global.json
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Anything else?
No response
The text was updated successfully, but these errors were encountered: