12

When trying to debug a Blazor client side app I keep getting the error

Debugging connection was closed. Reason: WebSocket disconnected

enter image description here

I open Chrome with "%programfiles(x86)%\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 https://localhost:50868/ and do not have any extensions installed in Chrome.

I followed the instructions https://learn.microsoft.com/en-us/aspnet/core/blazor/debug?view=aspnetcore-3.0 but no luck.

Have you guys ever faced this situation? Any idea on where I should be looking at?

Rui Lima
  • 7,185
  • 4
  • 31
  • 42
  • 5
    don't bother - client side debugger doesn't even show you locals at the moment, so even if you get the breakpoints to work you won't be able to see anything other than that you hit the breakpoint. for now, it's easiest to either debug in Server side mode or use Console.WriteLine ‍♂️ – Mister Magoo May 23 '19 at 13:42
  • 2
    That Magoo is so out of touch - in the latest 3.1 preview, you do get breakpoints and locals again, so it is worth trying. Make sure that after you launch chrome in debug mode and press shift-alt-D, you don't close that tab - you need the site running in tab 1 and the debug tools in another tab - the connection is between the two tabs. – Mister Magoo Nov 20 '19 at 11:49
  • I had the same issue, try this one I'm sure it will help: https://stackoverflow.com/a/63049777/893865 – Hamdan Dabbas Jul 23 '20 at 08:23

2 Answers2

3

I ran into the same thing. Since your URL contains https://localhost, the underlying issue might the same as in my case: the certificate served by the debugger proxy is unverified, and Chrome appears to quietly refuse to connect as a consequence. (I would therefore argue Chrome's error message is, at best, misleading, and possibly just incorrect.)

Long story short, try loading your Blazor site from the http (non-SSL) endpoint before launching the debugger.

Sören Kuklau
  • 19,454
  • 7
  • 52
  • 86
0

run server in debug mode: "dotnet run -c Debug" and check logs.

if u have error in log something like:

---> System.NullReferenceException: Object reference not set to an instance of an object. at WsProxy.BreakPointRequest.Parse(JObject args, DebugStore store)

remove breakpoints in Chrome DevTools window (Ctrl + Shift + D)

Misha Akopov
  • 12,241
  • 27
  • 68
  • 82