title: SignalR never start on iOS using Xamarin Forms
body: <p>I'm trying to use SignalR in my Xamarin Forms project.
  It works perfectly when I'm using Android (device or simulator).
  But using the same code on iOS, it hangs at <code>await hubConnection.StartAsync();</code></p>
  <p>I'm using Visual Studio 2022.
  XAML hot reload is disabled.
  I've tried adding the System.Memory and System.Buffers IncludeAssets None fix.</p>
  <p>Here's the code</p>
  <pre><code>public async Task StartObserving()
  {
      Uri signalRUri = new Uri(&quot;a-valid-uri-string-here&quot;);
      string jwt = await SecureStorage.GetAsync(SecureStorageKeys.IdToken);
  
      HubConnection hubConnection = new HubConnectionBuilder()
          .WithUrl(
              signalRUri,
              options =&gt;
              {
                  options.AccessTokenProvider = () =&gt; Task.FromResult(jwt);
                  options.WebSocketConfiguration = (clientWebSocketOptions) =&gt;
                  {
                      clientWebSocketOptions.RemoteCertificateValidationCallback = (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) =&gt;
                      {
                          return true;
                      };
                  };
                  options.HttpMessageHandlerFactory = (httpMessageHandler) =&gt;
                  {
                      if (httpMessageHandler is HttpClientHandler clientHandler)
                      {
                          clientHandler.ServerCertificateCustomValidationCallback = (HttpRequestMessage httpRequestMessage, X509Certificate2 certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) =&gt;
                          {
                              return true;
                          };
                      }
  
                      return httpMessageHandler;
                  };
              })
          .ConfigureLogging(logging =&gt;
          {
              logging.SetMinimumLevel(LogLevel.Trace);
              logging.AddConsole();
          })
          .Build();
  
      hubConnection.On&lt;string&gt;(
          &quot;Send&quot;,
          OnMessageReceivedFromSignalR);
  
      await hubConnection.StartAsync();
  }
  </code></pre>
  <p>Here's the SignalR log</p>
  <blockquote>
  <p>2022-03-23 13:21:01.453 MyApp.iOS[2581:54607]
  [40m[37mdbug[39m[22m[49m:
  Microsoft.AspNetCore.SignalR.Client.HubConnection[40]
  Registering handler for client method 'Send'.</p>
  <p>2022-03-23 13:21:01.464 MyApp.iOS[2581:54607]
  [40m[37mtrce[39m[22m[49m:
  Microsoft.AspNetCore.SignalR.Client.HubConnection[42]
  Waiting on Connection Lock in StartAsyncInner (/_/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs:247).</p>
  <p>2022-03-23 13:21:01.472 MyApp.iOS[2581:54607]
  [40m[37mtrce[39m[22m[49m:
  Microsoft.AspNetCore.SignalR.Client.HubConnection[80]
  The HubConnection is attempting to transition from the Disconnected state to the Connecting state.</p>
  <p>2022-03-23 13:21:01.476 MyApp.iOS[2581:54607]
  [40m[37mdbug[39m[22m[49m:
  Microsoft.AspNetCore.SignalR.Client.HubConnection[41]
  Starting HubConnection.</p>
  <p>2022-03-23 13:21:01.486 MyApp.iOS[2581:54607]
  [40m[37mdbug[39m[22m[49m:
  Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[1]
  Starting HttpConnection.</p>
  <p>2022-03-23 13:21:01.503 MyApp.iOS[2581:54607]
  [40m[37mdbug[39m[22m[49m:
  Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[5]
  Skipping dispose, connection is already disposed.</p>
  <p>2022-03-23 13:21:01.506 MyApp.iOS[2581:54607]
  [40m[37mtrce[39m[22m[49m:
  Microsoft.AspNetCore.SignalR.Client.HubConnection[80]
  The HubConnection is attempting to transition from the Connecting state to the Disconnected state.</p>
  <p>2022-03-23 13:21:01.506 MyApp.iOS[2581:54607]
  [40m[37mtrce[39m[22m[49m:
  Microsoft.AspNetCore.SignalR.Client.HubConnection[20]
  Releasing Connection Lock in StartAsyncInner (/_/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs:280).</p>
  </blockquote>
  <p>I'm getting the following Exception</p>
  <blockquote>
  <p>System.MissingMethodException: Method not found:
  Microsoft.AspNetCore.Http.Connections.NegotiationResponse
  Microsoft.AspNetCore.Http.Connections.NegotiateProtocol.ParseResponse(System.ReadOnlySpan1)
  at
  System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine]
  (TStateMachine&amp; stateMachine) [0x0002c] in
  /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:471
  at
  Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.NegotiateAsync
  (System.Uri url, System.Net.Http.HttpClient httpClient,
  Microsoft.Extensions.Logging.ILogger logger,
  System.Threading.CancellationToken cancellationToken) [0x0003d] in
  :0    at
  Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.GetNegotiationResponseAsync
  (System.Uri uri, System.Threading.CancellationToken cancellationToken)
  [0x00011] in :0    at
  Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.SelectAndStartTransport
  (Microsoft.AspNetCore.Connections.TransferFormat transferFormat,
  System.Threading.CancellationToken cancellationToken) [0x0017b] in
  :0    at
  Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsyncCore
  (Microsoft.AspNetCore.Connections.TransferFormat transferFormat,
  System.Threading.CancellationToken cancellationToken) [0x00127] in
  :0    at
  System.Threading.Tasks.ForceAsyncAwaiter.GetResult () [0x0000c] in
  :0    at
  Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsync
  (Microsoft.AspNetCore.Connections.TransferFormat transferFormat,
  System.Threading.CancellationToken cancellationToken) [0x00091] in
  :0    at
  Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync
  (System.Net.EndPoint endPoint, System.Threading.CancellationToken
  cancellationToken) [0x00114] in :0<br />
  at
  Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync
  (System.Net.EndPoint endPoint, System.Threading.CancellationToken
  cancellationToken) [0x001bf] in :0<br />
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncCore
  (System.Threading.CancellationToken cancellationToken) [0x000a9] in
  &lt;22c2b3ef3848439db8bf52b72cbcab20&gt;:0    at
  Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncInner
  (System.Threading.CancellationToken cancellationToken) [0x001a3] in
  &lt;22c2b3ef3848439db8bf52b72cbcab20&gt;:0    at
  System.Threading.Tasks.ForceAsyncAwaiter.GetResult () [0x0000c] in
  &lt;22c2b3ef3848439db8bf52b72cbcab20&gt;:0    at
  Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsync
  (System.Threading.CancellationToken cancellationToken) [0x00091] in
  &lt;22c2b3ef3848439db8bf52b72cbcab20&gt;:0    at MyApp.StartObserving ()
  [0x0027b] in C:\Dev\MobileApp\MyApp\MyApp\Services\CacheService.cs:279</p>
  </blockquote>