我有一个启用双工的服务,客户端注册自己以接收通知。在同一个 AppPool 中,我有另一个常规 Web 服务,客户端使用它与服务器通信。向此 Web 服务发送内容将触发所有连接的客户端的通知。在连接 12、13 或更多客户端之前,一切正常。然后,使用双工通道订阅/接收以及向其他服务发送内容都会变得慢得多。我已禁用 asp.net 兼容性,并且我的 Web 服务项目中没有 global.asax 文件,该文件可能会触发会话以减慢它的速度。
我的 Web 服务托管在 Windows Server 2008 上的 IIS7 中。请注意,我的客户端运行 SL4,但 Web 服务托管在 .NET 3.5 中。
以下是我的 web.config 文件的一些摘录:
<bindingExtensions>
<add name="pollingDuplexHttpBinding" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </bindingExtensions>
<pollingDuplexHttpBinding>
<binding name="pollingDuplexHttpBindingConfig"/>
</pollingDuplexHttpBinding>
<service name="WcfDuplexService.NotificationService"
behaviorConfiguration="ServiceBehavior">
<!-- Service Endpoints -->
<endpoint address=""
binding="pollingDuplexHttpBinding"
bindingConfiguration="pollingDuplexHttpBindingConfig"
contract="WcfDuplexService.INotificationService"
behaviorConfiguration="ServiceFullEndpointBehavior">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
<!-- Message Service -->
<service name="WcfDuplexService.MessageService"
behaviorConfiguration="ServiceBehavior">
<endpoint binding="customBinding"
bindingNamespace="http://csintra.net/MessageService"
contract="WcfDuplexService.IMessageService"
bindingConfiguration="binaryHttpBinding"
behaviorConfiguration="ServiceFullEndpointBehavior">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceThrottling maxConcurrentCalls="1024" maxConcurrentSessions="1024" maxConcurrentInstances="1024" />
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
提前致谢。