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

Restart Aspire using Rider doesn't wait for ports to be freed sometimes #7095

Closed
1 task done
Hona opened this issue Jan 14, 2025 · 2 comments
Closed
1 task done

Restart Aspire using Rider doesn't wait for ports to be freed sometimes #7095

Hona opened this issue Jan 14, 2025 · 2 comments
Assignees
Labels
area-orchestrator untriaged New issue has not been triaged
Milestone

Comments

@Hona
Copy link

Hona commented Jan 14, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When I am restarting the Aspire application, sometimes the ports are still bound from the last run. 
Image

This causes the following logs in the app host.

info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 9.0.0+01ed51919f8df692ececce51048a140615dc759d
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: C:\Repos\Revive\src\Hosting\Revive.AppHost
info: Aspire.Hosting.DistributedApplication[0]
      Now listening on: https://localhost:17243
info: Aspire.Hosting.DistributedApplication[0]
      Login to the dashboard at https://localhost:17243/login?t=c3f11510-4bb8-4bce-ba6f-088ce5e13531
fail: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      could not start the proxy {"ServiceName": {"name":"ui"}, "Reconciliation": 3, "error": "could not start the proxy for the service: listen tcp 127.0.0.1:6001: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."}
fail: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      could not start the proxy {"ServiceName": {"name":"api"}, "Reconciliation": 4, "error": "could not start the proxy for the service: listen tcp 127.0.0.1:5001: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."}
fail: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      could not start the proxy {"ServiceName": {"name":"api"}, "Reconciliation": 5, "error": "could not start the proxy for the service: listen tcp 127.0.0.1:5001: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."}
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
fail: Aspire.Hosting.Dcp.dcpctrl.ServiceReconciler[0]
      could not start the proxy {"ServiceName": {"name":"ui"}, "Reconciliation": 6, "error": "could not start the proxy for the service: listen tcp 127.0.0.1:6001: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."}

Expected Behavior

The restart should dispose/wait for the ports to be freed and successfully start up.

Steps To Reproduce

We haven't fully gotten the application running within random ports and whatnot. At the moment our UI & API projects are hardcoded ports, 5001 & 6001.

The AppHost is

var builder = DistributedApplication.CreateBuilder(args);

var api = builder.AddProject<Projects.Api>("api");

var ui = builder.AddProject<Projects.Portal>("ui").WithReference(api).WaitFor(api);

builder.Build().Run();

Note that the dashboard starts successfully saying the apps are running fine:

Image

Exceptions (if any)

Included exceptions in the app host logs above

.NET Version info

.NET SDK:
 Version:           9.0.101
 Commit:            eedb237549
 Workload version:  9.0.100-manifests.4a280210
 MSBuild version:   17.12.12+1cce77968

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.101\

.NET workloads installed:
 [aspire]
   Installation Source: SDK 9.0.100, VS 17.10.35027.167
   Manifest Version:    8.2.2/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
   Install Type:              Msi

 [wasm-tools]
   Installation Source: SDK 9.0.100
   Manifest Version:    9.0.0/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.current\9.0.0\WorkloadManifest.json
   Install Type:              Msi

 [wasm-tools-net8]
   Installation Source: SDK 9.0.100
   Manifest Version:    9.0.0/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.net8\9.0.0\WorkloadManifest.json
   Install Type:              Msi

Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.0
  Architecture: x64
  Commit:       9d5a6a9aa4

.NET SDKs installed:
  8.0.303 [C:\Program Files\dotnet\sdk]
  8.0.307 [C:\Program Files\dotnet\sdk]
  8.0.404 [C:\Program Files\dotnet\sdk]
  9.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  C:\Repos\Revive\global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Anything else?

It sometimes works when clicking restart, and it usually works when hitting stop all, wait a few seconds, then start again.

@davidfowl
Copy link
Member

davidfowl commented Jan 14, 2025

cc @karolz-ms @dbreshears

@davidfowl davidfowl added area-orchestrator untriaged New issue has not been triaged labels Jan 14, 2025
@dbreshears dbreshears added this to the 9.1 milestone Jan 14, 2025
@karolz-ms
Copy link
Member

This is most likely a duplicate of #6693. Should work with Aspire main 9.1.0-preview.1.25064.6 or newer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-orchestrator untriaged New issue has not been triaged
Projects
None yet
Development

No branches or pull requests

4 participants