Error with WebSocket

Nordin van der leije 31 Reputation points
2022-02-18T08:43:21.06+00:00

Hello I get the error: WebSocket connection to 'wss://localhost:54970/Dashboard.Server/' failed: Error in connection establishment: net::ERR_CONNECTION_RESET.

I get this on a new project, so what I do is

Start Visual Studio 2022.

Make a new Blazor WebAssembly App.

Set the framework to 6.0 with no Authentication type and the option Configure for HTTPS and ASP.NET Core hosted checked.

Then I run the Application with ISS Express.

Crome gives the error: WebSocket connection to 'wss://localhost:54970/Dashboard.Server/' failed: Error in connection establishment: net::ERR_CONNECTION_RESET.

I have no other programs or services running that could be interfering with the application, what am I doing wrong?

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,596 questions
{count} votes

Accepted answer
  1. Zhi Lv - MSFT 32,451 Reputation points Microsoft Vendor
    2022-02-23T05:26:55.923+00:00

    Hi @Nordin van der leije ,

    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 the application, even the web page can display well, if we check the F12 Console panel, we can see this error:

    177045-image.png

    This issue has been feedback to the Visual Studio forum: WebSocket connection to 'wss://...' failed. ASP .Net Core Web application. After update 17.1. You can also upvote it, and the Visual Studio team will review the feedback and notify you about the next steps.

    As a workaround, you can uninstall Visual Studio 2022 17.1.0 version and install a version before Visual Studio 2022 17.1.0, such as Visual Studio 2022 17.0.4 version (I checked this version, and this version has no Websocket connection error).


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Dillion

    1 person found this answer helpful.

7 additional answers

Sort by: Most helpful
  1. N, Jake 777 1 Reputation point
    2022-08-05T16:19:47.293+00:00

    I updated from VS2022 17.1 to 17.2.6 and the issue persists


  2. PatrickH 1 Reputation point
    2022-12-23T06:36:16.533+00:00

    The error event is fired when a connection with a WebSocket has been closed due to an error (some data couldn't be sent for example).

    Regards,
    Patrick

    0 comments No comments

  3. Craig Hoffman 0 Reputation points
    2024-07-23T03:32:11.1266667+00:00

    aspnetcore-browser-refresh.js:268 WebSocket connection to 'wss://localhost:44321/Project/' failed:

    Failed to load resource: net::ERR_CONNECTION_REFUSED

    Microsoft Visual Studio Community 2022 (64-bit) - Current

    Version 17.8.6

    .NET Framework Version 4.8.09032

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.