dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.41k stars 10k forks source link

VS 2022 17.9.4 Hot Reload Razor Pages Project run debug WebSocket failed to connect. #54769

Open xuanhe168 opened 7 months ago

xuanhe168 commented 7 months ago

Is there an existing issue for this?

Describe the bug

aspnetcore-browser-refresh.js:268 WebSocket connection to 'ws://localhost:58957/XuanHe.Web/' failed: (anonymous) @ aspnetcore-browser-refresh.js:268 getWebSocket @ aspnetcore-browser-refresh.js:265 (anonymous) @ aspnetcore-browser-refresh.js:16 aspnetcore-browser-refresh.js:19 WebSocket failed to connect. aspnetcore-browser-refresh.js:23 Unable to establish a connection to the browser refresh server.

image

Expected Behavior

No response

Steps To Reproduce

IDE image

Project configure

<Project Sdk="Microsoft.NET.Sdk.Web">

    <PropertyGroup>
        <TargetFramework>net7.0</TargetFramework>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
        <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
        <DockerfileContext>..\..</DockerfileContext>
    </PropertyGroup>

    <ItemGroup>
      <Compile Remove="Logs\**" />
      <Content Remove="Logs\**" />
      <EmbeddedResource Remove="Logs\**" />
      <None Remove="Logs\**" />
    </ItemGroup>
    <ItemGroup>
        <PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
        <PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
        ....

Exceptions (if any)

aspnetcore-browser-refresh.js:268 WebSocket connection to 'ws://localhost:58957/XuanHe.Web/' failed: (anonymous) @ aspnetcore-browser-refresh.js:268 getWebSocket @ aspnetcore-browser-refresh.js:265 (anonymous) @ aspnetcore-browser-refresh.js:16 aspnetcore-browser-refresh.js:19 WebSocket failed to connect. aspnetcore-browser-refresh.js:23 Unable to establish a connection to the browser refresh server.

image

.NET Version

8.0.202

Anything else?

No response

gthvidsten commented 2 months ago

@amcasey @MackinnonBuck Any updates on this? I'm running into the exact same issue now. I'm using VS 2022 17.10.4 and this happens with a clean project created from the Blazor Web App template with "Server" render mode.

chassq commented 1 month ago

@amcasey or @MackinnonBuck - As of today this is still an issue with a Server render mode app created anew from the template. The VS 2022 version is Version 17.12.0 Preview 2.0 and the dotnet SDK version is 8.0.303. The error we see int he MS Edge browser tools is: WebSocket connection to 'wss://localhost:44376/HPortal/' failed: WebSocket connection to wss://localhost:44376/HPortal failed:   | (anonymous) | @ | aspnetcore-browser-refresh.js:268