ASPNETCORE SignalR Android issue

Hello, I am trying to get Signal R library working on the android platform. I have based the implementation on this tutorial [Unity] Communicate with SignalR from Unity - DEV Community. I have a simple setup and it works in the editor and connects to my server. When I build for android the app launches but fails on the build part of creating the hub connection:

 HubCn = new HubConnectionBuilder().WithUrl("http://" + ServerURI + ":" + ServerPort.ToString() + "/ServerR").WithAutomaticReconnect().Build();

I attached a remote debugger and managed to get this stack trace:

  "System.ArgumentNullException: Value cannot be null.\nParameter name: obj\n  at System.Threading.Monitor.ReliableEnterTimeout (System.Object obj, System.Int32 timeout, System.Boolean& lockTaken) [0x00000] in <00000000000000000000000000000000>:0 \n  at System.Threading.Monitor.ReliableEnter (System.Object obj, System.Boolean& lockTaken) [0x00000] in <00000000000000000000000000000000>:0 \n  at System.Threading.Monitor.Enter (System.Object obj, System.Boolean& lockTaken) [0x00000] in <00000000000000000000000000000000>:0 \n  at Microsoft.Extensions.DependencyInjection.DependencyInjectionEventSource.ServiceProviderBuilt (Microsoft.Extensions.DependencyInjection.ServiceProvider provider) [0x00000] in <00000000000000000000000000000000>:0 \n  at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor (System.Collections.Generic.ICollection`1[T] serviceDescriptors, Microsoft.Extensions.DependencyInjection.ServiceProviderOptions options) [0x00000] in <00000000000000000000000000000000>:0 \n  at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider (Microsoft.Extensions.DependencyInjection.IServiceCollection services, Microsoft.Extensions.DependencyInjection.ServiceProviderOptions options) [0x00000] in <00000000000000000000000000000000>:0 \n  at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider (Microsoft.Extensions.DependencyInjection.IServiceCollection services) [0x00000] in <00000000000000000000000000000000>:0 \n  at Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder.Build () [0x00000] in <00000000000000000000000000000000>:0 \n  at CoreClientR.ConnectToServer () [0x00065] in C:\\KPX\\The Wheel\\ConsoleCore\\Assets\\Scripts\\CoreClientR.cs:267 \n  at CoreClientR.moConnectworker_DoWork (System.Object sender, System.ComponentModel.DoWorkEventArgs e) [0x00022] in C:\\KPX\\The Wheel\\ConsoleCore\\Assets\\Scripts\\CoreClientR.cs:357 \n  at System.ComponentModel.BackgroundWorker.OnDoWork (System.ComponentModel.DoWorkEventArgs e) [0x00000] in <00000000000000000000000000000000>:0 \n  at System.ComponentModel.BackgroundWorker.WorkerThreadStart (System.Object argument) [0x00000] in <00000000000000000000000000000000>:0 \n  at System.ComponentModel.BackgroundWorker.<RunWorkerAsync>b__27_0 (System.Object arg) [0x00000] in <00000000000000000000000000000000>:0 \n  at System.Threading.Tasks.Task.InnerInvoke () [0x00000] in <00000000000000000000000000000000>:0 \n  at System.Threading.Tasks.Task.Execute () [0x00000] in <00000000000000000000000000000000>:0 \n  at System.Threading.Tasks.Task.ExecutionContextCallback (System.Object obj) [0x00000] in <00000000000000000000000000000000>:0 \n  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 \n  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 \n  at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task& currentTaskSlot) [0x00000] in <00000000000000000000000000000000>:0 \n  at System.Threading.Tasks.Task.ExecuteEntry (System.Boolean bPreventDoubleExecution) [0x00000] in <00000000000000000000000000000000>:0 \n  at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <00000000000000000000000000000000>:0 \n  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <00000000000000000000000000000000>:0 \n  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <00000000000000000000000000000000>:0 "

I found this thread which has a similar issue [ Issue with System.Configuration.ConfigurationManager::get_AppSettings on iOS ](http:// ) but it seems their issue was resolved by using a NetStandard2.0 version of the library which is already what I am doing.

Libraries I am using are all the Net Standard 2.0 version this is my link.xml (I’ve added extra dependencies which may not be needed as I was trying to get it working so left them in for now)

<linker>
    <assembly fullname="Microsoft.AspNetCore.Connections.Abstractions" preserve="all"/>
    <assembly fullname="Microsoft.AspNetCore.Http.Connections.Client" preserve="all"/>
    <assembly fullname="Microsoft.AspNetCore.Http.Connections.Common" preserve="all"/>
    <assembly fullname="Microsoft.AspNetCore.Http.Features" preserve="all"/>
    <assembly fullname="Microsoft.AspNetCore.SignalR.Client.Core" preserve="all"/>
    <assembly fullname="Microsoft.AspNetCore.SignalR.Client" preserve="all"/>
    <assembly fullname="Microsoft.AspNetCore.SignalR.Common" preserve="all"/>
    <assembly fullname="Microsoft.AspNetCore.SignalR.Protocols.Json" preserve="all"/>
    <assembly fullname="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" preserve="all"/>
    <assembly fullname="Microsoft.Bcl.AsyncInterfaces" preserve="all"/>
    <assembly fullname="Microsoft.Extensions.DependencyInjection.Abstractions" preserve="all"/>
    <assembly fullname="Microsoft.Extensions.DependencyInjection" preserve="all"/>
    <assembly fullname="Microsoft.Extensions.Features" preserve="all"/>
    <assembly fullname="Microsoft.Extensions.Logging.Abstractions" preserve="all"/>
    <assembly fullname="Microsoft.Extensions.Logging" preserve="all"/>
    <assembly fullname="Microsoft.Extensions.Options" preserve="all"/>
    <assembly fullname="Microsoft.Extensions.Primitives" preserve="all"/>
    <assembly fullname="System.Diagnostics.DiagnosticSource" preserve="all"/>
    <assembly fullname="System.IO.Pipelines" preserve="all"/>
    <assembly fullname="System.Buffers" preserve="all"/>
    <assembly fullname="System.Memory" preserve="all"/>
    <assembly fullname="System.Runtime.CompilerServices.Unsafe" preserve="all"/>
    <assembly fullname="System.Text.Encodings.Web" preserve="all"/>
    <assembly fullname="System.Text.Json" preserve="all"/>
    <assembly fullname="System.Threading" preserve="all"/>
    <assembly fullname="System.Threading.Channels" preserve="all"/>
    <assembly fullname="System.Threading.Tasks.Extensions" preserve="all"/>
</linker>

Using:
Unity 2022.1.14f1
Vulkan Graphics API
API Level 28 (Android 9.0)
ILCPP
.Net Standard 2.1
Have unchecked to strip engine code as i thought maybe a library was getting removed during the build that is needed
Managed Stripping Level: Minimum

The error appears that a library/function SignalR uses to create the hub connection is missing from the build or maybe one of the dlls might not be compatible with android ?

Has anyone seen an error like this before and could point me in the right direction of a solution ? Or anyway to get more information when remote debugging would be useful to figure out what is actually causing the error and why.

Cheers

Managed to fix it using this work around SignalR 6.x doesn't work with android il2cpp · Issue #40569 · dotnet/aspnetcore · GitHub