title: Connecting to .Net Core 2.2 Web API SignalR hub from .Net 4.8 WPF client hangs
body: <p>I've got an ASP .Net Core 2.2 Web API with a .Net 4.8 WPF client consuming the API. Both are running locally on my Windows 10 PC in Visual Studio 2019 Community. I'm trying to connect the client to the API's SignalR Core Hub. There is only one-way communication from the server to the clients. The clients will never send data to the server.</p>
  
  <p>On the server I have a model:</p>
  
  <pre><code>public partial class Reading
  {
      public int Id { get; set; }
      public int? BaseId { get; set; }
      public double? Frequency { get; set; }
      public byte? Modulation { get; set; }
      public byte? Agc1 { get; set; }
      public byte? Agc2 { get; set; }
      public DateTime TimeStamp { get; set; }
  }
  </code></pre>
  
  <p>and a strongly typed hub:</p>
  
  <pre><code>public interface IChatClient
  {
      Task ReceiveMessage(int id, int? baseId, double? frequency, byte? modulation, byte? agc1, byte? agc2, DateTime timeStamp);
  }
  
  public class StronglyTypedChatHub : Hub&lt;IChatClient&gt;
  {
      public async Task SendMessage(Reading reading)
      {
          await Clients.All.ReceiveMessage(reading.Id, reading.BaseId, reading.Frequency, reading.Modulation, reading.Agc1, reading.Agc2, reading.TimeStamp);
      }
  
      public override async Task OnConnectedAsync()
      {
          await base.OnConnectedAsync();
      }
  
      public override async Task OnDisconnectedAsync(Exception exception)
      {
          await base.OnDisconnectedAsync(exception);
      }
  }
  </code></pre>
  
  <p>And in one of the API's controllers, I want to send data to all connected clients:</p>
  
  <pre><code>[Route("api/Readings")]
  public class ReadingsController : Controller
  {
      private readonly DbContext _context;
      private readonly IHubContext&lt;StronglyTypedChatHub, IChatClient&gt; _hubContext;
  
      public ReadingsController(DbContext context, IHubContext&lt;StronglyTypedChatHub, IChatClient&gt; hubContext)
      {
          _context = context;
          _hubContext = hubContext;
      }
  
      [HttpPost]
      public async Task&lt;IActionResult&gt; PostReading([FromBody] Reading reading)
      {
          _context.Readings.Add(reading);
          await _context.SaveChangesAsync();
  
          await _hubContext.Clients.All.ReceiveMessage(reading.Id, reading.BaseId, reading.Frequency, reading.Modulation, reading.Agc1, reading.Agc2, reading.TimeStamp);
  
          return CreatedAtAction("GetReading", new { id = reading.Id }, reading);
      }
  </code></pre>
  
  <p>And in Startup.cs:</p>
  
  <pre><code>    services.AddSignalR(options =&gt;
      {
          options.EnableDetailedErrors = true;
      });
  
      app.UseSignalR(route =&gt;
      {
          route.MapHub&lt;StronglyTypedChatHub&gt;("/chathub");
      });
  </code></pre>
  
  <p>On the client I have:</p>
  
  <pre><code>    using Microsoft.AspNetCore.SignalR.Client;
  
      private HubConnection hubConnection { get; set; }
  
      private void Window_Loaded(object sender, RoutedEventArgs e)
      {
          hubConnection = new HubConnectionBuilder()
          .WithUrl("http://localhost:44368/chatHub")
          .Build();
  
          hubConnection.Closed += async (error) =&gt;
          {
              await Task.Delay(new Random().Next(0, 5) * 1000);
              await hubConnection.StartAsync();
          };
  
          await hubConnection.StartAsync();
  
          hubConnection.On&lt;int, int?, byte?, double?, byte?, byte?, byte?, DateTime&gt;("SendMessage", (id, baseId, frequency, modulation, agc1, agc2, timeStamp) =&gt;
             this.Dispatcher.Invoke(() =&gt;
                 CallSomeMethod();
             )
          ); 
      }
  </code></pre>
  
  <p>I configure the Visual Studio solution to start up both projects and I hit F5. The API runs. Then the client runs but hangs on <code>await hubConnection.StartAsync();</code>
  No error messages or anything. It just hangs there. When the API's controller method triggers, and sends data to the hub, the client doesn't receive anything. Nothing is triggered on the client. I guess because it's hung on <code>await hubConnection.StartAsync();</code></p>
  
  <p>I'm brand new to SignalR. Any ideas where I'm going wrong would be greatly appreciated. Thank you!</p>