Aspnetcore: Unable to debug Blazor WebAssembly - WebSocket disconnected

Created on 12 Oct 2020  ยท  3Comments  ยท  Source: dotnet/aspnetcore

Describe the bug

Hello!
In Chrome and Edge, I get the following error when trying to debug a blazor webassembly project

image
Pressing reconnect just refreshes the page and I get the same error.

To Reproduce


I'm using a brand new project using dotnet new blazorwasm

Doesn't matter if I launch with the IIS Express or Project profiles. http vs https doesn't make any difference either.

  • launch using F5 and the a browser opens with the default template code running.

  • press alt-shift-d to start debug, 'Unable to find debuggable browser tab' appears.
    tab url: https://localhost:5001/_framework/debug?url=https%3A%2F%2Flocalhost%3A5001%2F

  • I run chrome --remote-debugging-port=9222 --user-data-dir="C:\Users\maill\AppData\Local\Temp\blazor-chrome-debug" https://localhost:5001/

  • with the new window in focus, press alt-shift-d and a new tab opens with the above error from Chrome (or Edge)
    tab url: http://localhost:9222/devtools/inspector.html?ws=127.0.0.1:57493/devtools/page/93569F7970AB545FA5F20E300518CDA7

This error occurred with both RC1 and RC2. I've tried this on 2 different machines (work and home) and have tried the troubleshooting steps described here

Any ideas? Thanks! :)

Exceptions (if any)


When running with the Project profile the dotnet process window spits out this exception:

got exception System.Net.WebSockets.WebSocketException (997): The server returned status code '500' when status code '101' was expected. at System.Net.WebSockets.WebSocketHandle.ConnectAsync(Uri uri, CancellationToken cancellationToken, ClientWebSocketOptions options) at Microsoft.WebAssembly.Diagnostics.DevToolsProxy.Run(Uri browserUri, WebSocket ideSocket) at Microsoft.WebAssembly.Diagnostics.DebugExtensions.<>c__DisplayClass2_0.<<UseDebugProxy>g__ConnectProxy|5>d.MoveNext()

Further technical details

Chrome 86.0.4240.75
Edge 86.0.622.38

  • Include the output of dotnet --info
    .NET SDK (reflecting any global.json):
    Version: 5.0.100-rc.2.20480.7
    Commit: 53e0c8c7f9

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.100-rc.2.20480.7\

Host (useful for support):
Version: 5.0.0-rc.2.20475.5
Commit: c5a3f49c88

.NET SDKs installed:
2.1.700 [C:\Program Files\dotnet\sdk]
2.2.300 [C:\Program Files\dotnet\sdk]
3.0.100-preview6-012264 [C:\Program Files\dotnet\sdk]
3.1.402 [C:\Program Files\dotnet\sdk]
5.0.100-preview.8.20417.9 [C:\Program Files\dotnet\sdk]
5.0.100-rc.1.20452.10 [C:\Program Files\dotnet\sdk]
5.0.100-rc.2.20480.7 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview6.19307.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0-preview.8.20414.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0-rc.1.20451.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0-rc.2.20475.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0-preview.8.20407.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0-rc.1.20451.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0-rc.2.20475.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0-preview.8.20411.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0-rc.1.20452.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0-rc.2.20475.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

  • The IDE (VS / VS Code/ VS4Mac) you're running on, and it's version
    VS Community 2019 Preview 16.8.0 Preview 3.2
Answered Resolved area-blazor feature-blazor-debugging

Most helpful comment

@captainsafia Thank you for looking at this. I figured it has to be something with my environment. Our security policies and infrastructure are pretty hardcore at work and we've issues like this before. That's why I tried this on my home machine, where I have full control to turn off the firewall and anti-virus and I still had the same result.

The disconnect error happens immediately after opening the debug tab (pressing alt-shift-d) in the second browser instance (the one started with debugging enabled)

Having said all that, I was able to come up with a workaround. I changed the launchSettings.json so that "launchBrowser": false. Then manually launched the browser with debugging enabled and it worked. So, I re-enabled "launchBrowser": true and
added another "browser" to the VS browser list (via Browse with...) that launches chrome with these arguments --remote-debugging-port=9222 --user-data-dir="%LOCALAPPDATA%\Temp\blazor-chrome-debug" and that works too.

It doesn't seem to like having the initial non-debug browser process running. Of course, if I close it then the VS stops debugging altogether. I'm still curious why the default doesn't work, but this is a viable workaround.
Thanks

All 3 comments

Thanks for opening this issue, @jmaillet.

I tried to repro this off a new blazorwasm template project in RC2 and via your repro project but wasn't able to.

Do you happen to have any proxies or firewalls running on your machine that might interfere with requests across local apps?

Also, do you get the disconnect error immediately after starting a debugging session or a while after?

@captainsafia Thank you for looking at this. I figured it has to be something with my environment. Our security policies and infrastructure are pretty hardcore at work and we've issues like this before. That's why I tried this on my home machine, where I have full control to turn off the firewall and anti-virus and I still had the same result.

The disconnect error happens immediately after opening the debug tab (pressing alt-shift-d) in the second browser instance (the one started with debugging enabled)

Having said all that, I was able to come up with a workaround. I changed the launchSettings.json so that "launchBrowser": false. Then manually launched the browser with debugging enabled and it worked. So, I re-enabled "launchBrowser": true and
added another "browser" to the VS browser list (via Browse with...) that launches chrome with these arguments --remote-debugging-port=9222 --user-data-dir="%LOCALAPPDATA%\Temp\blazor-chrome-debug" and that works too.

It doesn't seem to like having the initial non-debug browser process running. Of course, if I close it then the VS stops debugging altogether. I'm still curious why the default doesn't work, but this is a viable workaround.
Thanks

@jmaillet Thanks for posting back these details. It seems like the issue is related to the default browser launched from VS. If possible, can you attempt to debug again to trigger the failure state and file an issue via the "Report a problem" experience in VS. That should collect the logs necessary to debug.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rbanks54 picture rbanks54  ยท  3Comments

aurokk picture aurokk  ยท  3Comments

fayezmm picture fayezmm  ยท  3Comments

UweKeim picture UweKeim  ยท  3Comments

ermithun picture ermithun  ยท  3Comments