SoumyadipYT-OSS / .NET-development-issues

This repository is for discussing on .NET development and its frameworks, solving problems. It is open for .NET developers, community, engineers and .NET enthusiasts over the worldwide.
GNU General Public License v3.0
0 stars 0 forks source link

aspnetcore-browser-refresh.js error during inspect in the real time output for .NET Blazor (Linux/Windows) #1

Open SoumyadipYT-OSS opened 1 month ago

SoumyadipYT-OSS commented 1 month ago

I saw an error in the Blazor .NET 8 LTS during running on the localhost on my Linux system, after using the command 'dotnet watch' the output is showing properly no issue, but when I inspect on my chrome browser, I found an error on "aspnetcore-browser-refresh.js" file. Here is the code below:

function getWebSocket(url) { return new Promise((resolve, reject) => { const encryptedSecret = sharedSecret && sharedSecret.encryptedSharedSecret; const protocol = encryptedSecret ? encodeURIComponent(encryptedSecret) : []; const webSocket = new WebSocket(url, protocol); let opened = false;

  function onOpen() {
    opened = true;
    clearEventListeners();
    resolve(webSocket);
  }

  function onClose(event) {
    if (opened) {
      // Open completed successfully. Nothing to do here.
      return;
    }

    let error = 'WebSocket failed to connect.';
    if (event instanceof ErrorEvent) {
      error = event.error;
    }

    clearEventListeners();
    reject(error);
  }

}

In this funcion the following line raising an error during inspect: -> const webSocket = new WebSocket(url, protocol);

in the error box message it is shown that the WebSocket connection to 'wss://localhost:35755/' failed:'

If someone is familiar with this issue, please explain this why it is happening? And what is the solution for this?

SoumyadipYT-OSS commented 1 month ago

In the console window it is shown as this:

WebSocket connection to 'wss://localhost:35755/' failed:

aspnetcore-browser-refresh.js:268 (anonymous) @ aspnetcore-browser-refresh.js:268