BlazorMobile icon indicating copy to clipboard operation
BlazorMobile copied to clipboard

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

Open arivera12 opened this issue 4 years ago • 8 comments

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

arivera12 avatar Mar 22 '20 18:03 arivera12

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 !

Daddoon avatar Mar 22 '20 23:03 Daddoon

I will try your suggestion above right now!

arivera12 avatar Mar 23 '20 00:03 arivera12

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.

arivera12 avatar Mar 23 '20 01:03 arivera12

Otherwise send me a repro project

Daddoon avatar Mar 23 '20 01:03 Daddoon

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:

  • First launch UWP app in debug => Everything OK
  • Stop debug
  • Due to some actual limitation in the default template (but covered by the doc), i created a certificate for the UWP project: https://github.com/Daddoon/BlazorMobile#unable-to-connect-to-uwp-remotely-even-with-networkisolation-disabled
  • Run something similar to the sample of Microsoft

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 avatar Mar 23 '20 12:03 Daddoon

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();
        }
    }
}

Daddoon avatar Mar 23 '20 12:03 Daddoon

Edit: Moved this to a own issue since the error looks a bit different (https://github.com/Daddoon/BlazorMobile/issues/193)

I also have issues with 404 errors when starting the *.Blazor.Server project with F5 (Debug).

Steps to reproduce: dotnet new -i BlazorMobile.Templates::3.2.4-preview2.20160.5 dotnet new blazormobile -n TestApp open TestApp.sln set TestApp.Blazor.Server as startup project F5 (start debug) confirm dialog asking for ssl trust manually open http://127.0.0.1:5080

image

I pushed the source to https://github.com/vortex852456/BlazorMobile---TestApp

vortex852456 avatar Mar 29 '20 18:03 vortex852456

@vortex852456

Answered in https://github.com/Daddoon/BlazorMobile/issues/193

Daddoon avatar Mar 29 '20 18:03 Daddoon