dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.81k stars 453 forks source link

Error in Aspire run: failed to connect to IDE run session notification endpoint websocket bad handshake #5531

Closed mithileshz closed 1 month ago

mithileshz commented 1 month ago

Is there an existing issue for this?

Describe the bug

I have used the .NET Aspire Starter App template with .NET 8, Configure for HTTPS, Use Redis enabled, and an NUnit Test project to create a .NET Aspire project to create a project from scratch. Haven't changed any code, only pressing the run button in VS. The app fails to run with the following error. This only has an issue on this device, running the same code on a separate device (another PC) works completely fine.

info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.1.0+d304c5f6f15bcd4f34f1841b33870cfab88e6937
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: REDACTED
fail: Aspire.Hosting.Dcp.dcpctrl.IdeExecutableRunner[0]
      failed to connect to IDE run session notification endpoint, retrying...   {"error": "websocket: bad handshake"}
info: Aspire.Hosting.DistributedApplication[0]
      Now listening on: https://localhost:17230
info: Aspire.Hosting.DistributedApplication[0]
      Login to the dashboard at https://localhost:17230/login?t=ff3925101bf740a21d18c3f8143f5f74
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
fail: Aspire.Hosting.Dcp.dcpctrl.IdeExecutableRunner[0]
      failed to connect to IDE run session notification endpoint, retrying...   {"error": "websocket: bad handshake"}

There was a similar issue - https://github.com/dotnet/aspire/issues/4437 but the error messages are different. I have downgraded to .NET 8 from .NET 9 but that doesn't seem to have helped.

Expected Behavior

For the Aspire app to run.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version info

dotnet --version 8.0.400

Anything else?

Microsoft Visual Studio Community 2022 Version 17.11.2 VisualStudio.17.Release/17.11.2+35222.181 Microsoft .NET Framework Version 4.8.09032

Windows 11 Pro, Version 23H2

davidfowl commented 1 month ago

cc @karolz-ms

davidfowl commented 1 month ago

Are you using the same version of visual studio on both PCs?

maddymontaquila commented 1 month ago

Are you using the same version of visual studio on both PCs?

Also, do you have any proxies set up that might be interfering?

mithileshz commented 1 month ago

Are you using the same version of visual studio on both PCs?

Unfortunately not - On the other PC I am using (this one works fine) Microsoft Visual Studio Community 2022 Version 17.11.0 Preview 6.0 VisualStudio.17.Preview/17.11.0-pre.6.0+35125.118 Installed Version: Community

On the PC that has the issue, it is using the latest version of Visual Studio - it is an Intel based machine, whereas the one mentioned above is a AMD.

Also, do you have any proxies set up that might be interfering?

I do not have any proxies set up.

karolz-ms commented 1 month ago

@mithileshz make sure that you have the latest "ASPNET and web development" VS workload installed on the misbehaving machine (run Visual Studio Installer and update or repair as appropriate). The most likely reason for this error is that the version of the Aspire tools you have inside Visual Studio is outdated.

mithileshz commented 1 month ago

@karolz-ms I did a repair on visual studio and that hasn't helped.

I ran dotnet workload list and this is the output:

Installed Workload Id      Manifest Version      Installation Source
--------------------------------------------------------------------------------
aspire                     8.2.0/8.0.100         SDK 8.0.400, VS 17.11.35222.181
Here is all my visual studio info: ``` Microsoft Visual Studio Community 2022 Version 17.11.2 VisualStudio.17.Release/17.11.2+35222.181 Microsoft .NET Framework Version 4.8.09032 Installed Version: Community ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools ASA Service Provider 1.0 ASP.NET and Web Tools 17.11.230.51983 ASP.NET and Web Tools Azure App Service Tools v3.0.0 17.11.230.51983 Azure App Service Tools v3.0.0 Azure Data Lake Tools for Visual Studio 2.6.5000.0 Microsoft Azure Data Lake Tools for Visual Studio Azure Functions and Web Jobs Tools 17.11.230.51983 Azure Functions and Web Jobs Tools Azure Stream Analytics Tools for Visual Studio 2.6.5000.0 Microsoft Azure Stream Analytics Tools for Visual Studio C# Tools 4.11.0-3.24376.4+5e3a11e2e7f952da93f9d35bd63a2fa181c0608b C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Fabric.ApplicationInsights 1.0 Allows user to instrument their Service Fabric projects for Application Insights. GitHub Copilot 0.2.1634.3922 GitHub Copilot is an AI pair programmer that helps you write code faster and with less work. Microsoft Azure Hive Query Language Service 2.6.5000.0 Language service for Hive query Microsoft Azure Stream Analytics Language Service 2.6.5000.0 Language service for Azure Stream Analytics Microsoft Azure Tools for Visual Studio 2.9 Support for Azure Cloud Services projects Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines NuGet Package Manager 6.11.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ Razor (ASP.NET Core) 17.11.3.2442001+68650a7d94261bc56a1f4bc522c2ee35314b1abb Provides languages services for ASP.NET Core Razor. SQL Server Data Tools 17.11.38.0 Microsoft SQL Server Data Tools ToolWindowHostedEditor 1.0 Hosting json editor into a tool window TypeScript Tools 17.0.30715.2002 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 4.11.0-3.24376.4+5e3a11e2e7f952da93f9d35bd63a2fa181c0608b Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 17.11.0-beta.24317.3+c07c8ebad62f6629b36349381991a299598a8d74 Microsoft Visual F# Tools Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio. ```
davidfowl commented 1 month ago

Do you have any updates available?

mithileshz commented 1 month ago

No, I don't.

I've also uploaded my codebase to the repo here - https://github.com/mithileshz/AspireApp1

mithileshz commented 1 month ago

I've tried uninstalling, reinstalling VS, also done a repair. My dotnet workloads are also up to date.

If I run dotnet run in terminal without the connection to Visual studio, I get the information about the dashboard and when I try log in, it gives me a 400. For (https://localhost:17207/login?t=9d56afcdf8f1986f38da48107a8312b1) link

Bad Request - Invalid Hostname HTTP Error 400. The request hostname is invalid.

davidfowl commented 1 month ago

Very strange. What version of visual studio works? (the other PC)

cc @vijayrkn any ideas?

mithileshz commented 1 month ago

Microsoft Visual Studio Community 2022 Version 17.11.0 Preview 6.0 VisualStudio.17.Preview/17.11.0-pre.6.0+35125.118 Installed Version: Community

This is the version that's working. Let me try to install the same one on my broken machine and see if that helps.

mithileshz commented 1 month ago

Here's any extra information if it helps. When running dotnet run through cmd on the AppHost project, it doesn't have the same error as the initial one (failed to connect to IDE run session). It doesn't give any errors. However, when I click on the link to open the dashboard, I get the following in the browser.

Bad Request - Invalid Hostname

HTTP Error 400. The request hostname is invalid.
Here is the XHR: ``` { "log": { "version": "1.2", "creator": { "name": "Firefox", "version": "130.0" }, "browser": { "name": "Firefox", "version": "130.0" }, "pages": [ { "id": "page_1", "pageTimings": { "onContentLoad": -12386, "onLoad": 756 }, "startedDateTime": "2024-09-11T21:22:45.076+01:00", "title": "https://localhost:17230/login?t=77291f2e389a09a26ca12df35537e203" } ], "entries": [ { "startedDateTime": "2024-09-11T21:22:45.076+01:00", "request": { "bodySize": 0, "method": "GET", "url": "https://127.0.0.1:17230/login?t=77291f2e389a09a26ca12df35537e203", "httpVersion": "", "headers": [ { "name": "Host", "value": "127.0.0.1:17230" }, { "name": "User-Agent", "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0" }, { "name": "Accept", "value": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8" }, { "name": "Accept-Language", "value": "en-GB,en;q=0.5" }, { "name": "Accept-Encoding", "value": "gzip, deflate, br, zstd" }, { "name": "Connection", "value": "keep-alive" }, { "name": "Upgrade-Insecure-Requests", "value": "1" }, { "name": "Sec-Fetch-Dest", "value": "document" }, { "name": "Sec-Fetch-Mode", "value": "navigate" }, { "name": "Sec-Fetch-Site", "value": "cross-site" }, { "name": "Priority", "value": "u=0, i" }, { "name": "Pragma", "value": "no-cache" }, { "name": "Cache-Control", "value": "no-cache" } ], "cookies": [], "queryString": [ { "name": "t", "value": "77291f2e389a09a26ca12df35537e203" } ], "headersSize": 564 }, "response": { "status": 0, "statusText": "", "httpVersion": "", "headers": [], "cookies": [], "content": { "mimeType": "", "size": 0, "encoding": "base64", "text": "" }, "redirectURL": "", "headersSize": 0, "bodySize": 0 }, "cache": {}, "timings": { "blocked": -1, "dns": 2066, "connect": 0, "ssl": 0, "send": 0, "wait": 0, "receive": 0 }, "time": 2066, "_securityState": "insecure", "pageref": "page_1" }, { "startedDateTime": "2024-09-11T21:23:01.604+01:00", "request": { "bodySize": 0, "method": "GET", "url": "https://localhost:17230/login?t=77291f2e389a09a26ca12df35537e203", "httpVersion": "HTTP/2", "headers": [ { "name": "Host", "value": "localhost:17230" }, { "name": "User-Agent", "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0" }, { "name": "Accept", "value": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8" }, { "name": "Accept-Language", "value": "en-GB,en;q=0.5" }, { "name": "Accept-Encoding", "value": "gzip, deflate, br, zstd" }, { "name": "Connection", "value": "keep-alive" }, { "name": "Upgrade-Insecure-Requests", "value": "1" }, { "name": "Sec-Fetch-Dest", "value": "document" }, { "name": "Sec-Fetch-Mode", "value": "navigate" }, { "name": "Sec-Fetch-Site", "value": "none" }, { "name": "Sec-Fetch-User", "value": "?1" }, { "name": "Priority", "value": "u=0, i" }, { "name": "Pragma", "value": "no-cache" }, { "name": "Cache-Control", "value": "no-cache" } ], "cookies": [], "queryString": [ { "name": "t", "value": "77291f2e389a09a26ca12df35537e203" } ], "headersSize": 578 }, "response": { "status": 400, "statusText": "", "httpVersion": "HTTP/2", "headers": [ { "name": "content-type", "value": "text/html" }, { "name": "date", "value": "Wed, 11 Sep 2024 20:23:01 GMT" }, { "name": "server", "value": "Kestrel" }, { "name": "content-length", "value": "334" }, { "name": "X-Firefox-Spdy", "value": "h2" } ], "cookies": [], "content": { "mimeType": "text/html", "size": 334, "text": "\r\nBad Request\r\n\r\n

Bad Request - Invalid Hostname

\r\n

HTTP Error 400. The request hostname is invalid.

\r\n" }, "redirectURL": "", "headersSize": 135, "bodySize": 469 }, "cache": {}, "timings": { "blocked": -1, "dns": 0, "connect": 513, "ssl": 32, "send": 0, "wait": 42, "receive": 0 }, "time": 587, "_securityState": "secure", "serverIPAddress": "127.0.0.1", "connection": "17230", "pageref": "page_1" }, { "startedDateTime": "2024-09-11T21:23:02.592+01:00", "request": { "bodySize": 0, "method": "GET", "url": "https://localhost:17230/favicon.ico", "httpVersion": "HTTP/2", "headers": [ { "name": "Host", "value": "localhost:17230" }, { "name": "User-Agent", "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0" }, { "name": "Accept", "value": "image/avif,image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5" }, { "name": "Accept-Language", "value": "en-GB,en;q=0.5" }, { "name": "Accept-Encoding", "value": "gzip, deflate, br, zstd" }, { "name": "Connection", "value": "keep-alive" }, { "name": "Referer", "value": "https://localhost:17230/login?t=77291f2e389a09a26ca12df35537e203" }, { "name": "Sec-Fetch-Dest", "value": "image" }, { "name": "Sec-Fetch-Mode", "value": "no-cors" }, { "name": "Sec-Fetch-Site", "value": "same-origin" }, { "name": "Priority", "value": "u=6" }, { "name": "Pragma", "value": "no-cache" }, { "name": "Cache-Control", "value": "no-cache" }, { "name": "TE", "value": "trailers" } ], "cookies": [], "queryString": [], "headersSize": 534 }, "response": { "status": 400, "statusText": "", "httpVersion": "HTTP/2", "headers": [ { "name": "content-type", "value": "text/html" }, { "name": "date", "value": "Wed, 11 Sep 2024 20:23:01 GMT" }, { "name": "server", "value": "Kestrel" }, { "name": "content-length", "value": "334" }, { "name": "X-Firefox-Spdy", "value": "h2" } ], "cookies": [], "content": { "mimeType": "text/html", "size": 334, "text": "\r\nBad Request\r\n\r\n

Bad Request - Invalid Hostname

\r\n

HTTP Error 400. The request hostname is invalid.

\r\n" }, "redirectURL": "", "headersSize": 135, "bodySize": 469 }, "cache": {}, "timings": { "blocked": -1, "dns": 0, "connect": 0, "ssl": 0, "send": 0, "wait": 4, "receive": 0 }, "time": 4, "_securityState": "secure", "serverIPAddress": "127.0.0.1", "connection": "17230", "pageref": "page_1" } ] } } ```

Here is the output of dotnet run


info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.2.0+75fdcff28495bdd643f6323133a7d411df71ab70
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: {REDACTED}AppHost
info: Aspire.Hosting.DistributedApplication[0]
      Now listening on: https://localhost:17230
info: Aspire.Hosting.DistributedApplication[0]
      Login to the dashboard at https://localhost:17230/login?t=b83f990577356a834d9483a2dcfddcc4
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
davidfowl commented 1 month ago

Bad Request - Invalid Hostname

HTTP Error 400. The request hostname is invalid.

Can you share a screenshot of this?

mithileshz commented 1 month ago

image

davidfowl commented 1 month ago

This looks like a proxy on your machine doing some blocking of traffic.

mithileshz commented 1 month ago

I've checked any proxies running with the chrome://net-export/ tool (using this guide), it doesn't mention anything. I don't have any proxies configured in my windows settings either, so I am not sure where it is picking up a proxy from? Any idea or tools I could use?

mithileshz commented 1 month ago

running netsh winhttp show proxy in terminal returns:

Current WinHTTP proxy settings:

    Direct access (no proxy server).
davidfowl commented 1 month ago

Do you have fiddler?

mithileshz commented 1 month ago

I do not, I can install it if it will provide extra info?

davidfowl commented 1 month ago

Nope I’m just wondering what is returning that bad request page. It’s likely not the dashboard.

mithileshz commented 1 month ago

So apparently the only thing that fixed this was a windows reinstall. Not really sure what the issue was.

karolz-ms commented 1 month ago

I am sorry we could not get to the bottom of it, but I am glad you are finally unblocked.