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

Weird behaviour on starting up Aspire app #2539

Closed
adamtrip opened this issue Feb 29, 2024 · 20 comments
Closed

Weird behaviour on starting up Aspire app #2539

adamtrip opened this issue Feb 29, 2024 · 20 comments

Comments

@adamtrip
Copy link

Sometimes on starting an Aspire app via VS 2022, it immediately launches the browser saying "No resources found" and throws an error.

image

Error: Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="Error connecting to subchannel.", DebugException="System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it.")
 ---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|285_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
   at Grpc.Net.Client.Balancer.Internal.SocketConnectivitySubchannelTransport.TryConnectAsync(ConnectContext context)
   --- End of inner exception stack trace ---
   at Grpc.Net.Client.Balancer.Internal.ConnectionManager.PickAsync(PickContext context, Boolean waitForReady, CancellationToken cancellationToken)
   at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpMessageInvoker.<SendAsync>g__SendAsyncWithTelemetry|6_0(HttpMessageHandler handler, HttpRequestMessage request, CancellationToken cancellationToken)
   at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)
   at Grpc.Net.Client.Internal.Retry.RetryCallBase`2.GetResponseCoreAsync()
   at Aspire.Dashboard.Model.DashboardClient.<>c__DisplayClass23_0.<<EnsureInitialized>g__ConnectAsync|2>d.MoveNext() in /_/src/Aspire.Dashboard/Model/DashboardClient.cs:line 158
--- End of stack trace from previous location ---
   at Aspire.Dashboard.Components.ApplicationName.OnInitializedAsync() in /_/src/Aspire.Dashboard/Components/Controls/ApplicationName.razor.cs:line 32
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

Sometimes it fixes itself, with a VS restart, and other times I have to reboot my PC to make it work again.
This did happen on preview versions 3, 4 and 5 so no specific version bound to this (I think)

@davidfowl
Copy link
Member

The dashboard can't connect to the resource server (the app host) for some reason. Is it consistent? I'm going to close this and link the issue here

@davidfowl
Copy link
Member

A few questions:

  1. When it happens were you launching in VS or outside?
  2. Did you use F5 or CTRL+F5 if in VS?
  3. The next time it happens, can you look at the environment variables on both the dashboard process and the app host?

@adamtrip
Copy link
Author

Is it consistent?

Yes, happens every hour or two.

  1. When it happens were you launching in VS or outside?

In VS

  1. Did you use F5 or CTRL+F5 if in VS?

Just F5

3. The next time it happens, can you look at the environment variables on both the dashboard process and the app host?

How can I do that?

@davidfowl
Copy link
Member

Yes, happens every hour or two.

This is good news, we might be able to pin it down.

How can I do that?

https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer

I'm guessing that something gets into a bad state wrt the ports chosen causing some errors.

Can you also turn the logging verbosity up on the AppHost project once it starts happening? (in appsettings.json)

@adamtrip
Copy link
Author

As soon as I encounter that issue again, I'll debug it with that tool.

I'm guessing that something gets into a bad state wrt the ports chosen causing some errors.

I believe that that might be the case because changing the localhost port on launchsettings doesn't work, the dashboard does not launch, at least on preview 3, on preview 5 haven't tested

@adamtrip
Copy link
Author

adamtrip commented Mar 1, 2024

I believe that that might be the case because changing the localhost port on launchsettings doesn't work, the dashboard does not launch, at least on preview 3, on preview 5 haven't tested

Adding ASPNETCORE_URLS env var fixes the dashboard port change not loading. I was only changing the applicationUrl env var.
Maybe also add ASPNETCORE_URLS variable to the default launchSettings similar to DOTNET_DASHBOARD_OTLP_ENDPOINT_URL

As soon as I encounter that issue again, I'll debug it with that tool.

Today didn't happen yet, still waiting for it to debug it and provide extra info.

@joaojvf
Copy link

joaojvf commented Mar 7, 2024

@adamtrip can you give more explanation about how to fix it? Don't update any port of my application, but I've the same error.

https://github.com/joaojvf/AspirePoc/blob/add-aspire/src/AspirePoc.UI.Api/appsettings.json

@adamtrip
Copy link
Author

adamtrip commented Mar 8, 2024

@joaojvf I've updated to 8.0.0-preview.5.24155.1 and I have not encountered this issue since

@joaojvf
Copy link

joaojvf commented Mar 10, 2024

@adamtrip do you update the .NET Aspire for this version? Because the last one that I found is the 8.0.0-preview.3.24105.21.

@adamtrip
Copy link
Author

@davidfowl
Copy link
Member

The rule about using daily builds is that you are following the commits to understand the changes. We're in rapid fire mode to beware of breakage 😄

@joaojvf
Copy link

joaojvf commented Mar 12, 2024

Thank you guys! I tried re-implement the Aspire in my project, and worked! I use this project to create a medium post for my company initiative. If you like to see the code and post are here:
post: https://medium.com/@jferreira.ti/implementing-net-aspire-preview-3-24-988235098554
code: https://github.com/joaojvf/AspirePoc

@adamtrip
Copy link
Author

@davidfowl since I reported it, it never happened but it happened today. here's the env vars

AppHost
image
image

Dashboard
image
image

@davidfowl
Copy link
Member

The dashboard is connecting to 55072 and it’s failing. Unfortunately I think we need to add logs to narrow this down. It’s possible the app hosts’ resource server failed to start or there’s some caching bug that we have reporting the wrong url

@adamtrip
Copy link
Author

out of curiosity I did a net stat and with the app stopped I saw this

[Aspire.Dashboard.exe]
  TCP    127.0.0.1:16051        adam-pc:0              LISTENING
 [Aspire.Dashboard.exe]
  TCP    127.0.0.1:45654        adam-pc:0              LISTENING

@davidfowl
Copy link
Member

Take a look at the TCP/IP section on the apphost process.

@adamtrip
Copy link
Author

adamtrip commented Mar 13, 2024

image

@davidfowl
Copy link
Member

The apphost should be listening as well.

@adamtrip
Copy link
Author

Found this port missmatch on the logs

info: Aspire.Hosting.Dcp.DcpHostService[0]
      Starting DCP with arguments: start-apiserver --monitor 56024 --detach --kubeconfig "C:\Users\Adam\AppData\Local\Temp\aspire.vmi0wofx.g0i\kubeconfig"
(...)
info: Aspire.Hosting.Dcp.api-server[0]
      API server started        {"Address": "::1", "Port": 58196}

@davidfowl
Copy link
Member

Different port. that's the orchestrator not aspire.hosting (even though logs come through that console)

@github-actions github-actions bot locked and limited conversation to collaborators Apr 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants