11

Reagrdless of whether I run the application with or without the debugger attached, and whether it's run from VS or via command line (dotnet watch run) I cannot get the Hot Reload websocket to connect.

The framework automatically adds the aspnetcore-browser-refresh.js file to my page, which attempts to open a websocket connection to a localhost port on machine, but it always fails.

I tried creating new blazor server project to see if the issue still happened...it did.

I am using Visual Studio 2022 and targeting .net 6. Both are up to date.

Has anyone else run into a similar issue and/or have any ideas to try to resolve?

olesakn
  • 176
  • 1
  • 6

3 Answers3

7

It's a bug with VS2022 that should be addressed in the near future;

I bet you have 17.1.0 or 17.1.1;

As a workaround, you can uninstall Visual Studio 2022 17.1.0 version and install and older version; VS2019 also works but you might not get .net 6 with that.

Dan M
  • 770
  • 1
  • 9
  • 18
  • 2
    I can confirm that I have issue with 17.1.0 and 17.1.1; however, I *thought* I had this happen prior to upgrading to 17.1, but I could be wrong there. I have not seen much reporting with other people with same issue. Do you have any details about the issue or any info on the ticket to allow us to track when this gets patched in a future VS update? – olesakn Mar 14 '22 at 12:26
  • 2
    See [this](https://developercommunity2.visualstudio.com/t/WebSocket-connection-to-wss:-fail/1670519?q=ERR_CONNECTION_RESET&ftype=problem&space=8&stateGroup=active&sort=newest) link - it looks like a fix is awaiting release – John M Mar 15 '22 at 12:35
  • Can confirm the error has gone with VS 17.2.0 preview 2.1 (like stated in the [link](https://developercommunity2.visualstudio.com/t/WebSocket-connection-to-wss:-fail/1670519?q=ERR_CONNECTION_RESET&ftype=problem&space=8&stateGroup=active&sort=newest) above). Hope this fix will be released soon. – Robin Windey Mar 30 '22 at 15:05
  • Just installed 17.1.4 release and can confirm it is still an issue. – Jesper Wilfing Apr 13 '22 at 19:18
  • Still an issue for me in 17.3.5 – Enkode Oct 08 '22 at 23:39
  • Just downloaded 17.4.4 and the issue seems to be resolved in that release. So far so good. – Cydaps Feb 03 '23 at 21:01
  • for 17.4.4 I experience the exact same bug. – tinmanjk Feb 10 '23 at 19:07
  • Still an issue for me in 17.5.1 – Christiaan van Bergen Mar 01 '23 at 14:02
  • Still an issue for me in 17.5.2 – Christopher King Mar 20 '23 at 19:11
  • Confirmed that still happening in v17.5.2 Visual Studio for Mac, however hot-reload works fine, but it is not neat to see this error in chrome developer console – erik.aortiz Mar 28 '23 at 03:05
1

I got the same error too when updating to 17.1.1. But I can overtake it by changing the version to preview via Visual Studio Installer. For this case i have update to 17.2.0 preview 2 and the error gone :) .

Sorry for my bad English.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Sigit Budi
  • 51
  • 11
0

Any chance you've overriden the base href of your application? If so, this is a known issue logged here - https://github.com/dotnet/aspnetcore/issues/39554 and seems there is currently no fix to it. Good thing is it is planned for .NET 7