我有一个托管在 Windows 服务中的自托管 WCF 服务。我的绑定设置为 basicHttpBinding。
当我运行服务时,我运行 netsh http show servicestate 并且我看到我的服务正在监听;但是,我似乎无法正确配置参数。
在 IIS 下托管时,它的执行速度会慢 20%,所以我想自己托管。如何配置我的自托管 WCF 服务的参数以匹配 IIS?我特别关注的参数是超时、最大连接数、超时和最大请求数。我试图提出服务行为;但是,它什么也没做。我在 HTTP/Parameters 下的注册表中添加了 MaxConnections 也没有运气。任何帮助表示赞赏。
以下是在 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:
这是我自托管时的输出:
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
这是我的服务配置文件:
<?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>