title: Problem with hosting WCF service in a Windows Service
body: <p>I have a WCF service that is hosted inside a Windows Service. The Windows Service has a <code>OnStart</code> method like this:</p>
  
  <pre><code>protected override void OnStart(string[] args)
  {
    serviceHost = new ServiceHost(typeof (RouterService));
    serviceHost.Open();
  }
  </code></pre>
  
  <p>It's quite minimal now, since I'm trying to find the problem. Since I have not put any error handling here, any exceptions at this point should have stopped the service from starting up properly. It would start, and then automatically stop again immediately.</p>
  
  <p>My config file for the WCF service looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;startup&gt;
      &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/&gt;
    &lt;/startup&gt;
    &lt;system.serviceModel&gt;
      &lt;services&gt;
        &lt;service name="WcfService.RouterService"
                 behaviorConfiguration="serviceBehavior" &gt;
          &lt;endpoint address="RouterService" contract="WcfService.IRouterService" binding="wsHttpBinding" bindingConfiguration="NoSecurity" /&gt;
          &lt;endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding" /&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:8000"/&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;bindings&gt;
        &lt;wsHttpBinding&gt;
          &lt;binding name="NoSecurity"&gt;
            &lt;security mode="None" /&gt;
          &lt;/binding&gt;
        &lt;/wsHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="serviceBehavior" &gt;
            &lt;serviceMetadata httpGetEnabled="true" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
    &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>In addition, I have added the NETWORK SERVICE user (who the service is running as to be able to listen to Http at the specified port:</p>
  
  <pre><code>netsh http add urlacl url=http://+:8000/ user="NETWORK SERVICE"
  </code></pre>
  
  <p>Now, in the client, I choose <code>Add Service Reference</code>. I can find the server, and VS also manage to create the configuration and make the proxy files. Then inside the client, I make an instance of the proxy, and open it. Everything still fine. But upon calling the first method on proxy, I get the following exception:</p>
  
  <p><em>The HTTP service located at <a href="http://localhost:8000/RouterService">http://localhost:8000/RouterService</a> is too busy.</em></p>
  
  <p>I know that my client is the only thing that is trying to connect to this service, so why do I get this error message then? And how can I fix this? It does not time out when it tries to call the method, it throws the exception almost immediately.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Ok, now I found out that my TestServer (not the Windows Client one, but a console application) also gives the same error. Earlier today it didn't, and neither the WCF service or TestServer are changed.</p>
  
  <p>Then I tried changing the port to 8080 instead of 8000, and it worked. Then I tried the same for the Windows Service, and that also worked (after running the <code>netsh http</code> command on the new port)</p>
  
  <p>So something has happened to http on port 8000 for some reason. I have tried restarting the system also of course. </p>
  
  <p>This is puzzling me, so if anyone has any idea what is going on here I would appreciate it.</p>