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

Authentication errors when launching portal from VS. #4247

Closed
PaybackMan opened this issue May 21, 2024 · 22 comments
Closed

Authentication errors when launching portal from VS. #4247

PaybackMan opened this issue May 21, 2024 · 22 comments

Comments

@PaybackMan
Copy link

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.<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

@timheuer
Copy link
Member

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

@cecilphillip
Copy link

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....

@davidfowl
Copy link
Member

@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.

@LanceMcCarthy
Copy link

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 😎

@cecilphillip
Copy link

cecilphillip commented May 22, 2024

@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

@davidfowl
Copy link
Member

cc @danegsta @timheuer @baronfel

@domalansilva
Copy link

domalansilva commented May 23, 2024

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

@PaybackMan
Copy link
Author

Thanks all that really helped!

@cecilphillip
Copy link

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.

@davidfowl davidfowl added this to the 8.1 milestone Jun 11, 2024
@davidfowl
Copy link
Member

@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

@SvenVandenbrande
Copy link

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

@adamint
Copy link
Member

adamint commented Jun 14, 2024

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?

@karolz-ms
Copy link
Member

I am not able to reproduce either.

What I did:

  1. Built the app that @SvenVandenbrande described here An unhandled error has occurred on the Aspire Dashboard #4499 (comment) (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... 🤔

@adamint
Copy link
Member

adamint commented Jun 14, 2024

@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.

@karolz-ms
Copy link
Member

@adamint sure.

I just realised that there was another repro mentioned here #4247 (comment) need to try that.

@karolz-ms
Copy link
Member

karolz-ms commented Jun 14, 2024

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

@SvenVandenbrande
Copy link

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...

@karolz-ms
Copy link
Member

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 #4518

@joperezr
Copy link
Member

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.

@davidfowl
Copy link
Member

Moving this to high.

@davidfowl davidfowl modified the milestones: 8.1, Backlog Jun 25, 2024
@davidfowl
Copy link
Member

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

@karolz-ms
Copy link
Member

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

@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 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