Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

[Bug] Blazor is trying to connect to WS blazor server error gets fired in console. #182

Open
arivera12 opened this issue Mar 22, 2020 · 8 comments

Comments

@arivera12
Copy link

I run myapp.blazor and this error gets fired in the console
image

I run myapp.blazor.server and css aren't getting loaded as well the same errors are being fired.
image

@Daddoon
Copy link
Owner

Daddoon commented Mar 22, 2020

I didn't had this error with my tests.
Can you try to delete bin and obj folders and test again ?

Otherwise, can you send a repro project ?
Thanks !

@arivera12
Copy link
Author

I will try your suggestion above right now!

@arivera12
Copy link
Author

hmm doesn't seems to work I will take a deeper look to se if I can see whats wrong if no succeed I share a solution with the error.

@Daddoon
Copy link
Owner

Daddoon commented Mar 23, 2020

Otherwise send me a repro project

@Daddoon
Copy link
Owner

Daddoon commented Mar 23, 2020

I had made some extensive test with a template project from scratch i don't had any issue.

My test:

  • dotnet new -i BlazorMobile.Templates::3.2.3-preview2.20160.5
  • dotnet new blazormobile -n MyProjectName

I wanted to do a remote debug session with UWP for the test, so:

New-SelfSignedCertificate -Type Custom -Subject "CN=MyProject Software, O=MyProject Corporation, C=US" -KeyUsage DigitalSignature -FriendlyName "MyProject Cert" -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")

  • In Package.appxmanifest, in Packages tab, click on Select certificate and select your new created certificate
  • Save
  • Copy the package family name (greyed out) content
  • On a cmd prompt, launch with YourPackageFamilyName changed by your package name instead:

CheckNetIsolation loopbackexempt -is -n=YourPackageFamilyName

  • Save
  • Launch UWP without Debug (CTRL+F5)
  • Launch your Blazor project in Debug this time. Remote debugging IP is by default 127.0.0.1 so it should be fine.
  • It should load, and if you look in the browser console it should have connected to the remote app.
  • If you click on the test dialog button in BlazorMobile tab in the template, you should see the dialog in the native app (not in the browser obviously).

To me there is no problem with the default template.

What was your configuration while testing ? What were you debugging ?

@Daddoon
Copy link
Owner

Daddoon commented Mar 23, 2020

Also it's weird, you neither have css or else, and the WebSocket URI that should be present by default seems to return nothing in your case.

Does your Program.cs file look like this ?

using BlazorMobile.Common;
using BlazorMobile.Common.Services;
using myapp.Blazor.Helpers;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;

namespace myapp.Blazor
{
    public class Program
    {
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);

            builder.Services.AddBaseAddressHttpClient();

            #region Services registration

            ServicesHelper.ConfigureCommonServices(builder.Services);

            #endregion

            #region DEBUG

            //Only if you want to test WebAssembly with remote debugging from a dev machine
            BlazorMobileService.EnableClientToDeviceRemoteDebugging("127.0.0.1", 8888);

            #endregion

            BlazorMobileService.Init((bool success) =>
            {
                Console.WriteLine($"Initialization success: {success}");
                Console.WriteLine("Device is: " + BlazorDevice.RuntimePlatform);
            });

            builder.RootComponents.Add<MobileApp>("app");

            await builder.Build().RunAsync();
        }
    }
}

@vortex852456

This comment has been minimized.

@Daddoon
Copy link
Owner

Daddoon commented Mar 29, 2020

@vortex852456

Answered in #193

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants