HotReload displays WebSocket connection error message in browser console for ASP.NET Core app run in VS2022 but not on dotnet watch run
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Describe the bug
HotReload displays:
WebSocket connection to 'wss://localhost:62139/AppName/' failed:
message in browser console for ASP.NET Core app run in VS2022. This is happening ONLY in VS2022 (version 17.1.0 ) but not on dotnet watch run
session. Then all works ok.
This is probably originating from /_framework/aspnetcore-browser-refresh.js
script. JS stack trace:
(anonymous) @aspnetcore-browser-refresh.js:234
getWebSocket @aspnetcore-browser-refresh.js:231
(anonymous) @aspnetcore-browser-refresh.js:15
Expected Behavior
Error should not be displayed and presumably the connection endpoint shoyuld be the same for VS2022 and dotnet watch run
Steps To Reproduce
Create any dotnet core app (dotnet 6) and enaable hotreload in VS2022. Ctrl+F5 (no debug tun) Result:
Exceptions (if any)
No response
.NET Version
6.0.200
Anything else?
When run from VS2022 I see this as web socket end-point (line 10 in aspnetcore-browser-refresh.js):
const webSocketUrls = 'wss://localhost:62139/NoHotReloadWithServiceWorker/,ws://localhost:62140/NoHotReloadWithServiceWorker/'.split(',');
when run from dotnet watch
it is like this:
const webSocketUrls = 'wss://localhost:61215,ws://localhost:61216'.split(',');
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (3 by maintainers)
Top Results From Across the Web
VS 2022 Hot Reload - web socket fails to open in ...
I cannot get the Hot Reload websocket to connect. The framework automatically adds the aspnetcore-browser-refresh.
Read more >problem of aspnetcore-browser-refresh.js connection failed.
I have reproduced the problem, the issue relates the Visual Studio 2022 17.1 version. By using Visual Studio 2022 17.1.0 version, after running...
Read more >.NET 6 Hot Reload and "Refused to connect to ws ...
DasBlog is a pretty large and cool app and we noticed immediately upon Mark upgrading it to .NET 6 that we were unable...
Read more >Websocket Connection To Wss Localhost Failed
I am connection. on('message', function message(data) { console. var socket ... 0 ) but not on dotnet watch run session. browser websocket is...
Read more >NET 6 Hot Reload in Visual Studio 2022, VS Code ... - YouTube
NET 6 Hot Reload in Visual Studio 2022, VS Code, and NOTEPAD?!? Why this makes your C# life so much easier.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is this issue resolve?
it looks like has been solved after update vs 2022 to version 17.1.5