aspire icon indicating copy to clipboard operation
aspire copied to clipboard

Authentication errors when launching portal from VS.

Open PaybackMan opened this issue 1 year ago β€’ 9 comments

Has anyone seen this when launching Aspire portal from VS? This is from Inspecting the portal page while it keeps trying to reload itself after the exception. I'm using Preview 6.

Grpc.Core.RpcException: Status(StatusCode="Unauthenticated", Detail="Bad gRPC response. HTTP status code: 401") at Grpc.Net.Client.Internal.Retry.RetryCallBase`2.GetResponseCoreAsync() at Aspire.Dashboard.Model.DashboardClient.<>c__DisplayClass27_0.<<EnsureInitialized>g__ConnectAsync|2>d.MoveNext() in //src/Aspire.Dashboard/Model/DashboardClient.cs:line 238 --- 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

PaybackMan avatar May 21 '24 18:05 PaybackMan

Hi @PaybackMan we just released GA bits today! Can you update all packages to 8.0.0?

timheuer avatar May 21 '24 20:05 timheuer

I had the same issue via the command line after I updated to GA. I ended up recreating the app host project and copying the code over. Not sure what the source of that was. Checked browser session, checked packages, ran the project with and without an IDE....

cecilphillip avatar May 22 '24 00:05 cecilphillip

@cecilphillip next time it happens, when you kill the apphost, see if the dashboard process is already running. I saw this randomly this week and it was an old dashboard instance trying to connect to the apphost with the wrong key. Each launch the apphost generates a new secret and gives it to the dashboard. If the dashboard doesn't die properly, it'll still be up and on the next launch, you'll be using the stale instance with the wrong key.

davidfowl avatar May 22 '24 08:05 davidfowl

I am also seeing this, but it was because of a partial deploy (the initial launch only spun up 2 of the projects because I stopped it in VS2022 instead of the conhost). After explicitly killing everything with Ctrl+C, the next time it launched everything was good.

Thanks David, you saved me some early morning headache 😎

LanceMcCarthy avatar May 22 '24 13:05 LanceMcCarthy

@davidfowl that was it. I found a few of those processes running. However... it seems stopping the dotnet run process isn't killing the dashboard (on my machine), so I have to manually end it on subsequent runs

cecilphillip avatar May 22 '24 22:05 cecilphillip

cc @danegsta @timheuer @baronfel

davidfowl avatar May 23 '24 05:05 davidfowl

Killing the "Aspire.Dashboard.exe" task worked for me.

domalansilva avatar May 23 '24 15:05 domalansilva

Thanks all that really helped!

PaybackMan avatar May 23 '24 16:05 PaybackMan

Dug into this some more today. I think the issue I'm having is different from @PaybackMan and is happening because of an endpoint I'm trying to expose.

I have a custom resource that looks like this.

public class ConsulResource(string name) : ContainerResource(name);

public static class DistributedApplicationBuilderExtensions
{
    public static IResourceBuilder<ConsulResource> AddConsulContainer(
        this IDistributedApplicationBuilder builder, string name, int? port = null, int? dnsPort = null, string tag = "latest")
    {
        var consul = new ConsulResource(name);
        return builder.AddResource(consul)
            .WithImage("hashicorp/consul", tag)
            .WithImageRegistry("docker.io")
            .WithHttpEndpoint(port, 8500, "api")
            .WithEndpoint("dns", ea =>
            {
                ea.Protocol = ProtocolType.Udp;
                ea.Port = dnsPort;
                ea.TargetPort = 8600;
            });        
    }
}

If I remove that last call to .WithEndpoint("dns"), everything works fine.

cecilphillip avatar May 23 '24 18:05 cecilphillip

@karolz-ms I can reproduce this when using main and dotnet run. I haven't been able to reproduce in VS but it seems like something about using dotnet run slows down shutdown enough to make this happen.

Turning on the dashboard logs via the apphost I get this on each run:

info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.1.0-dev
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: C:\dev\git\aspire\playground\mongo\Mongo.AppHost
info: Aspire.Hosting.DistributedApplication[0]
      Now listening on: https://localhost:15887
info: Aspire.Hosting.DistributedApplication[0]
      Login to the dashboard at https://localhost:15887/login?t=a1923ec4a77da07d1fbae1eddee12479
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
warn: Aspire.Hosting.Dashboard.Microsoft.AspNetCore.Server.Kestrel[0]
      Overriding address(es) 'https://localhost:15887, http://localhost:15888'. Binding to endpoints defined via IConfiguration and/or UseKestrel() instead.
fail: Aspire.Hosting.Dashboard.Microsoft.Extensions.Hosting.Internal.Host[11]
      Hosting failed to start
fail: Aspire.Hosting.Dashboard[0]
      Unhandled exception. System.IO.IOException: Failed to bind to address https://127.0.0.1:15887: address already in use.
fail: Aspire.Hosting.Dashboard[0]
       ---> Microsoft.AspNetCore.Connections.AddressInUseException: Only one usage of each socket address (protocol/network address/port) is normally permitted.
fail: Aspire.Hosting.Dashboard[0]
       ---> System.Net.Sockets.SocketException (10048): Only one usage of each socket address (protocol/network address/port) is normally permitted.
fail: Aspire.Hosting.Dashboard[0]
         at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, Boolean disconnectOnFailure, String callerName)
fail: Aspire.Hosting.Dashboard[0]
         at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
fail: Aspire.Hosting.Dashboard[0]
         at System.Net.Sockets.Socket.Bind(EndPoint localEP)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportOptions.CreateDefaultBoundListenSocket(EndPoint endpoint)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
fail: Aspire.Hosting.Dashboard[0]
         --- End of inner exception stack trace ---
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.TransportManager.BindAsync(EndPoint endPoint, ConnectionDelegate connectionDelegate, EndpointConfig endpointConfig, CancellationToken cancellationToken)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.<>c__DisplayClass28_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
fail: Aspire.Hosting.Dashboard[0]
      --- End of stack trace from previous location ---
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context, CancellationToken cancellationToken)
fail: Aspire.Hosting.Dashboard[0]
         --- End of inner exception stack trace ---
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context, CancellationToken cancellationToken)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.EndpointsStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(ListenOptions[] listenOptions, AddressBindContext context, Func`2 useHttps, CancellationToken cancellationToken)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_1(IHostedService service, CancellationToken token)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
fail: Aspire.Hosting.Dashboard[0]
         at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
fail: Aspire.Hosting.Dashboard[0]
         at Aspire.Dashboard.DashboardWebApplication.Run() in C:\dev\git\aspire\src\Aspire.Dashboard\DashboardWebApplication.cs:line 598
fail: Aspire.Hosting.Dashboard[0]
         at Program.<Main>$(String[] args) in C:\dev\git\aspire\src\Aspire.Dashboard\Program.cs:line 7

davidfowl avatar Jun 11 '24 07:06 davidfowl

Had the same issue #4499

That was version 8.0.0 of the package. The aspire.dashboard was indeed still in my TaskManager, after closing. Updated to 8.0.1, now the aspire.dashboard is gone every time when I stop running it in VS

Killing it manually was also a solution on 8.0.0

SvenVandenbrande avatar Jun 14 '24 06:06 SvenVandenbrande

I am unable to reproduce this using dotnet run --project playground/TestShop/AppHost/AppHost.csproj on mac. @davidfowl are you using a windows machine? Which project are you running?

adamint avatar Jun 14 '24 17:06 adamint

I am not able to reproduce either.

What I did:

  1. Built the app that @SvenVandenbrande described here https://github.com/dotnet/aspire/discussions/4499#discussion-6817155 (web frontend, web api, Redis Postgres).
  2. Run it 10 times via dotnet run in quick succession (including ctrl-C early enough to induce DCP/Docker dependency check failures sometimes).

The dashboard comes up fine every dime... πŸ€”

karolz-ms avatar Jun 14 '24 17:06 karolz-ms

@karolz-ms if the issue users are reporting is that the process isn’t stopped on close, can I reassign to you? We do not have any input in that process.

adamint avatar Jun 14 '24 18:06 adamint

@adamint sure.

I just realised that there was another repro mentioned here https://github.com/dotnet/aspire/issues/4247#issuecomment-2127747960 need to try that.

karolz-ms avatar Jun 14 '24 18:06 karolz-ms

OK I can definitively reproduce the problem with an UDP endpoint. Looks like DCP is crashing 😞 Investigating...

Edit: I am going to open a separate issue for the repro that @cecilphillip reported, and keep open this one in case someone finds a repro for the original issue that @PaybackMan reported

karolz-ms avatar Jun 14 '24 18:06 karolz-ms

And it's not always. As I retried it with the older version and it's just working at this moment.

Always closing the process... But happy that you could reproduce it one way...

SvenVandenbrande avatar Jun 14 '24 18:06 SvenVandenbrande

Edit: I am going to open a separate issue for the repro that @cecilphillip reported, and keep open this one in case someone finds a repro for the original issue that @PaybackMan reported

For reference, that was https://github.com/dotnet/aspire/issues/4518

karolz-ms avatar Jun 17 '24 19:06 karolz-ms

We think this one should be done , but we never got to consistently repro. If folks are updating to 8.1 and still seeing this, please let us know.

joperezr avatar Jun 24 '24 19:06 joperezr

Moving this to high.

davidfowl avatar Jun 25 '24 23:06 davidfowl

Moving out of 8.1 as there were fixes made. If you can reproduce the issue, please let us know.

If you are willing to try out daily builds to see if they solve your issues, go here:

https://github.com/dotnet/aspire/blob/main/docs/using-latest-daily.md

davidfowl avatar Jun 25 '24 23:06 davidfowl

Aspire 8.1 release contains the fixes mentioned above. Closing for now; if someone encounters this again, please open a new issue.

karolz-ms avatar Aug 07 '24 00:08 karolz-ms