title: AspNet Core Integration Test For SignalR
body: <p>Is there away to test <code>SignalR</code> using <code>TestServer</code> generated as part of integration tests (<a href="https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests</a> view=aspnetcore-2.1)?</p>
  
  <p>All my retries failed to perform handshake to the <code>TestServer</code> instance fail with Exception: <code>System.Net.Sockets.SocketException : No connection could be made because the target machine actively refused it</code></p>
  
  <p>Running in <code>Debug</code>/<code>Console</code>/<code>IIS</code> works perfectly</p>
  
  <p><strong>Server Code</strong></p>
  
  <pre><code> public void Configure(...)
   {
       ...
       app.UseSignalR(router =&gt; router.MapHub&lt;MockHub&gt;("/ws"));
       ...
  }
  </code></pre>
  
  <p><strong>TestCode</strong></p>
  
  <pre><code>        ...
          var server = factory.Server;
          var connection = new HubConnectionBuilder()
                .WithUrl(server.BaseAddress)
                .Build();
          await connection.StartAsync();
  </code></pre>