title: How to have a Self Hosting signalR server running as as NetCore Console App
body: <p>I would like to create a SignalR Self hosting Server within a console app using .NetCore.</p>
  <p>I am completely new to web development and .Net Core but would like to use SignalR as a real-time web based protocol. No web page is required, and so I would like to have a console app.</p>
  <p>I have successfully tested the .Net Framework example below and would like to replicate this using  .Net Core 3.1, so that it can run on Linux. However I cannot find any suitable examples.</p>
  <pre><code>using System;
  using Microsoft.AspNet.SignalR;
  using Microsoft.Owin.Hosting;
  using Owin;
  using Microsoft.Owin.Cors;
  
  namespace SignalRSelfHost
  {
      class Program
      {
          static void Main(string[] args)
          {
              // This will *ONLY* bind to localhost, if you want to bind to all addresses
              // use http://*:8080 to bind to all addresses. 
              // See http://msdn.microsoft.com/library/system.net.httplistener.aspx 
              // for more information.
              string url = &quot;http://localhost:8088&quot;;
              using (WebApp.Start&lt;Startup&gt;(url))
              {
                  Console.WriteLine(&quot;Server running on {0}&quot;, url);
                  Console.ReadLine();
              }
          }
      }
      class Startup
      {
          public void Configuration(IAppBuilder app)
          {
              app.UseCors(CorsOptions.AllowAll);
              app.MapSignalR();
          }
      }
      public class MyHub : Hub
      {
          public void Send(string name, string message)
          {
              Clients.All.addMessage(name, message);
              Clients.All.addMessage(name, &quot;World&quot;);
          }
      }
  }
  </code></pre>
  <p>In an attempt to use Owin to create a server console app I have the following code and this compiles, however complains about no server service being registered when I run the program. Could someone please advise what to add to have a web server without web page? The example I copied specified UseKestrel() but I think this is for a web page, so I think I need something else.</p>
  <pre><code>using System.Collections.Generic;
  using System.Globalization;
  using System.IO;
  using System.Text;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Builder;
  using Microsoft.Extensions.DependencyInjection;
  
  namespace OwinConsole
  {
      public class Startup
      {
          // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
          public void ConfigureServices(IServiceCollection services)
          {
          }
  
          public void Configure(IApplicationBuilder app)
          {
              app.UseOwin(pipeline =&gt;
              {
                  pipeline(next =&gt; OwinHello);
              });
          }
  
          public Task OwinHello(IDictionary&lt;string, object&gt; environment)
          {
              string responseText = &quot;Hello World via OWIN&quot;;
              byte[] responseBytes = Encoding.UTF8.GetBytes(responseText);
  
              // OWIN Environment Keys: http://owin.org/spec/spec/owin-1.0.0.html
              var responseStream = (Stream)environment[&quot;owin.ResponseBody&quot;];
              var responseHeaders = (IDictionary&lt;string, string[]&gt;)environment[&quot;owin.ResponseHeaders&quot;];
  
              responseHeaders[&quot;Content-Length&quot;] = new string[] { responseBytes.Length.ToString(CultureInfo.InvariantCulture) };
              responseHeaders[&quot;Content-Type&quot;] = new string[] { &quot;text/plain&quot; };
  
              return responseStream.WriteAsync(responseBytes, 0, responseBytes.Length);
          }
      }
  }
  using System.IO;
  using Microsoft.AspNetCore.Hosting;
  
  namespace OwinConsole
  {
      public class Program
      {
          public static void Main(string[] args)
          {
              var host = new WebHostBuilder()
                  .UseContentRoot(Directory.GetCurrentDirectory())
                  .UseStartup&lt;Startup&gt;()
                  .Build();
  
              host.Run();
          }
      }
  }
  </code></pre>
  <p>Thanks.</p>