Domanda

I have a self hosted WCF service I'm hosting in a Windows Service. My binding is setup as a basicHttpBinding.

When I am running the service, I run netsh http show servicestate and I see my service is listening; however, I cannot seem to configure the parameters properly.

When hosted under IIS, it performs about 20% slower so I want to self host. How can I configure the parameters of my self hosted WCF service to match IIS? The parameters I'm particularly looking at are timeouts, Max Connections, Timeouts, and Max Requests. I've attempted to put a Service Behavior; however, it doesn't do anything. I've added the MaxConnections in the Registry under HTTP/Parameters without luck either. Any help is appreciated.

Here is the output when hosted under IIS:

Server session ID: F9000000200015DA

    Version: 2.0
    State: Active
    Properties:
        Max bandwidth: 4294967295
        Timeouts:
            Entity body timeout (secs): 120
            Drain entity body timeout (secs): 120
            Request queue timeout (secs): 65535
            Idle connection timeout (secs): 120
            Header wait timeout (secs): 120
            Minimum send rate (bytes/sec): 240
    URL groups:
    URL group ID: F600000040001737
        State: Active
        Request queue name: MyService
        Properties:
            Max bandwidth: inherited
            Max connections: 4294967295
            Timeouts:
                Entity body timeout (secs): 120
                Drain entity body timeout (secs): 120
                Request queue timeout (secs): 65535
                Idle connection timeout (secs): 120
                Header wait timeout (secs): 0
                Minimum send rate (bytes/sec): 0
            Logging information:
                Log directory: C:\inetpub\logs\LogFiles\W3SVC2
                Log format: 0
            Authentication Configuration:
                Authentication schemes enabled:
            Number of registered URLs: 1
            Registered URLs:
                HTTP://*:80/

Request queues:
    Request queue name: MyService
        Version: 2.0
        State: Active
        Request queue 503 verbosity level: Basic
        Max requests: 3000
        Number of active processes attached: 1
        Controller process ID: 1400
        Process IDs:

Here is the output when I'm self hosting:

Server session ID: FC00000120000229

    Version: 2.0
    State: Active
    Properties:
        Max bandwidth: 4294967295
        Timeouts:
            Entity body timeout (secs): 120
            Drain entity body timeout (secs): 120
            Request queue timeout (secs): 120
            Idle connection timeout (secs): 120
            Header wait timeout (secs): 120
            Minimum send rate (bytes/sec): 150
    URL groups:
    URL group ID: FB000001400005DE
        State: Active
        Request queue name: Request queue is unnamed.
        Properties:
            Max bandwidth: inherited
            Max connections: inherited
            Timeouts:
                Timeout values inherited
            Number of registered URLs: 1
            Registered URLs:
                HTTP://+:80/MyService/

Request queues:
    Request queue name: Request queue is unnamed.
        Version: 2.0
        State: Active
        Request queue 503 verbosity level: Basic
        Max requests: 1000

Here is my service config file:

<?xml version="1.0"?> <configuration>   <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyThrottle">
          <serviceThrottling maxConcurrentCalls="3000" maxConcurrentSessions="3000"
            maxConcurrentInstances="12500" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="MyConfig" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
          maxReceivedMessageSize="10485760" useDefaultWebProxy="false">
          <readerQuotas maxDepth="999999999" maxStringContentLength="999999999"
            maxArrayLength="999999999" maxBytesPerRead="999999999" maxNameTableCharCount="999999999" />
          <security mode="None">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="MyThrottle" name="This.MyService">
        <endpoint address="http://localhost:80/MyService" binding="basicHttpBinding"
          bindingConfiguration="MyConfig" name="MyService"
          contract="This.IMyService" />
      </service>
    </services>   </system.serviceModel> </configuration>
È stato utile?

Soluzione

Here is the official response from Microsoft HTTP.SYS team:

The “Max Connections” = HttpServerConnectionsProperty output has a different meaning than “Max Requests” = HttpServerQueueLengthProperty.

HttpListener does not let you set the Max Connections property (HttpServerConnectionsProperty) for the URL group or the Max requests property (HttpServerQueueLengthProperty) for the request queue, so WCF cannot set http.sys settings when self-hosting through code.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top