question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

HotReload displays:

image

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: image

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:closed
  • Created 2 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
elgabatocommented, Mar 31, 2022

Is this issue resolve?

2reactions
SH-Engineer02commented, Apr 21, 2022

it looks like has been solved after update vs 2022 to version 17.1.5

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found