title: Why does my Self-Hosted NancyFX application hang when running over HTTPS?
body: <p>I have written a Nancy <a href="https://github.com/NancyFx/Nancy/wiki/Self-Hosting-Nancy" rel="nofollow">self-hosted</a> application. This is intended to run as an API without any client interface. It is therefore a console application that is deployed via <a href="http://topshelf-project.com/" rel="nofollow">TopShelf</a> (see code below)</p>
  
  <p>Everything works just fine as long as I run over standard http. However I need to secure this API by running it over <em>https</em> (see SSL Setup section below)</p>
  
  <p>Once I have the service running over https the service hangs after the first call. To be clear, the first call works fine and I receive the correct response. Howvere something must have gone wrong because the second call hangs and only returns after it times-out.</p>
  
  <p>Is this a bug in the Nancy self hosting or have I made a mistake in my code / setup?</p>
  
  <p>Thanks.</p>
  
  <p><strong>The Console Application</strong></p>
  
  <pre><code>public class Program
  {
      [STAThread]
      public static void Main()
      {
          HostFactory.Run(config =&gt; {
              config.Service&lt;SelfHost&gt;(service =&gt;
              {
                  service.ConstructUsing(name =&gt; new SelfHost());
                  service.WhenStarted(s=&gt; s.Start());
                  service.WhenStopped(s=&gt; s.Stop());
              });
              config.RunAsLocalSystem();
              config.StartAutomatically();
          });
      }
  }
  </code></pre>
  
  <p><strong>The Self Hosting Controller</strong></p>
  
  <pre><code>public class SelfHost
  {
      private NancyHost nancyHost;
  
      public void Start()
      {
          var config = new HostConfiguration { 
              UnhandledExceptionCallback = e =&gt; Log.Error("Self Host Exception", e) 
          };
          nancyHost = new NancyHost(config, new Uri("https://myurl.com:8081"));
          nancyHost.Start();
      }
  
      public void Stop()
      {
          nancyHost.Stop();
      }
  }
  </code></pre>
  
  <p><strong>The Nancy Module</strong></p>
  
  <pre><code>public class RootModule : NancyModule
  {
      public RootModule()
      {
          Get["/"] = _ =&gt;
          {
              return "Service is Running";
          };
      }
  }
  </code></pre>
  
  <p><strong>SSL Setup</strong></p>
  
  <pre><code>netsh http add sslcert ipport=0.0.0.0:8081 certhash=XXXX880f5e33288a4c88bb1d321d88d44d2XXXX appid={xxxxxxxx-e7e9-xxxx-94dd-5634a472f42d}
  netsh http add urlacl url=https://myurl.com:8081/ user=MYDOMAIN\my-admin-user
  </code></pre>
  
  <p><strong>Edit 1</strong></p>
  
  <p>Following the advice of @Steven Robbins I have now recompiled using the pre-release nuget packages. Unfortunately the latest pre-release packages have not solved the problem, however I do now have some very intersting log information.</p>
  
  <p><strong>Logs</strong></p>
  
  <pre><code>//First Call - success
  12:51:10|GET| /
  12:51:10|OK | Service is Running    
  
  //Second Call failure                                                                                                                                                                                                                        
  12:51:12|Self Host Exception
  12:51:12| Method    :AsyncProcessClientCertificate
  12:51:12| Message   :Element not found
  
  //Restart Service
  12:51:41|Stopping Service
  12:51:41|Self Host Exception
  12:51:41| Method    :EndGetContext
  12:51:41| Message   :The I/O operation has been aborted because of either a thread exit or an application request
  12:51:41|Self Host Exception
  12:51:41| Method    :EndGetContext
  12:51:41| Message   :The I/O operation has been aborted because of either a thread exit or an application request
  
  12:51:43|Starting on https://myurl.net:8081
  </code></pre>