title: AspNetCore.SignalR : Cannot start a connection that is not in the Initial state
body: <p>I have troubles to get my ASP.NET Core SignalR app working.</p>
  
  <p>I have this server-side code : </p>
  
  <pre><code>public class PopcornHub : Hub
  {
      private int Users;
  
      public async Task BroadcastNumberOfUsers(int nbUser)
      {
          await Clients.All.InvokeAsync("OnUserConnected", nbUser);
      }
  
      public override async Task OnConnectedAsync()
      {
          Users++;
          await BroadcastNumberOfUsers(Users);
          await base.OnConnectedAsync();
      }
  
      public override async Task OnDisconnectedAsync(Exception exception)
      {
          Users--;
          await BroadcastNumberOfUsers(Users);
          await base.OnDisconnectedAsync(exception);
      }
  }
  </code></pre>
  
  <p>whose SignalR Hub service is configured as :</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      ...
      services.AddSignalR();
      ...
  }
  
  public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  {
      ...
  
      app.UseSignalR(routes =&gt;
      {
          routes.MapHub&lt;PopcornHub&gt;("popcorn");
      });
  
      ...
  }
  </code></pre>
  
  <p>In my client-side (WPF app), I have a service : </p>
  
  <pre><code>public class PopcornHubService : IPopcornHubService
  {
      private readonly HubConnection _connection;
  
      public PopcornHubService()
      {
          _connection = new HubConnectionBuilder()
              .WithUrl($"{Utils.Constants.PopcornApi.Replace("/api", "/popcorn")}")
              .Build();
          _connection.On&lt;int&gt;("OnUserConnected", (message) =&gt;
          {
  
          });
      }
  
      public async Task Start()
      {
          await _connection.StartAsync();
      }
  }
  </code></pre>
  
  <p>My issue is that, when I call Start() method, I get the exception "Cannot start a connection that is not in the Initial state".
  The issue occurs either locally or in Azure.</p>
  
  <p>The SignalR endpoint is fine but no connection can be established. What am I missing?</p>