title: .NET Core SignalR client doesn't connect to ASP.NET Core hub
body: <p>I have an ASP.NET Core web API with a SignalR Hub and a .NET Core console app that acts as a client for the hub.</p>
  
  <p>The console app throws the following error when trying to connect:</p>
  
  <pre><code>System.AggregateException
    HResult=0x80131500
    Message=One or more errors occurred. (StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.HttpConnection+HttpConnectionResponseContent, Headers:
  {
    Date: Mon, 20 May 2019 18:12:44 GMT
    Server: Kestrel
    Content-Length: 0
  })
    Source=System.Private.CoreLib
    StackTrace:
     at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
     at System.Threading.Tasks.Task.Wait()
     at SurveyApp.NotificationClient.Program.Main(String[] args) in C:\Users\user\source\repos\SurveyApp\SurveyApp.NotificationClient\Program.cs:line 16
  
  Inner Exception 1:
  HttpClientException: StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.HttpConnection+HttpConnectionResponseContent, Headers:
  {
    Date: Mon, 20 May 2019 18:12:44 GMT
    Server: Kestrel
    Content-Length: 0
  }
  </code></pre>
  
  <p>I have tried all kinds of renaming of routes and hubs, but it still doesn't work. Also tried the solution shown here since it is a similar issue, but still not result: <a href="https://stackoverflow.com/questions/30502433/httpclientexception-when-connecting-to-working-hub-from-signalr-net-client/30503436">HttpClientException when connecting to working hub from SignalR .NET Client</a></p>
  
  <p>Server:
  DI registration: </p>
  
  <pre><code>            services.AddSignalR();
  </code></pre>
  
  <p>Middleware registration:</p>
  
  <pre><code>            ...
  
              app.UseSignalR(route =&gt;
              {
                  route.MapHub&lt;NotificationHub&gt;("/notificationhub");
              });
              app.UseMvc();
  </code></pre>
  
  <p>Hub class:</p>
  
  <pre><code>public class NotificationHub : Hub
      {
          public Task SendMessage(string message)
          {
              return Clients.All.SendAsync(message);
          }
  
          public override Task OnConnectedAsync()
          {
              Console.WriteLine("A client connected");
              return base.OnConnectedAsync();
          }
      }
  </code></pre>
  
  <p>Client code:</p>
  
  <pre><code>static void Main(string[] args)
          {
              var connection = new HubConnection("https://localhost:5001/notificationhub");
              connection
                  .CreateHubProxy("NotificationHub")
                  .On&lt;string&gt;("ReceiveNotification", Console.WriteLine);
              connection.Start().Wait();
              Console.WriteLine("Connection started");
              Console.ReadKey();
          }
  </code></pre>
  
  <p>When I don't call Wait() after connection.Start(), I do not get any error, but the client still doesn't connect. I'm running .NET Core 2.2 both on the server and the client and the version for the SignalR nuget is 2.4.1</p>