【发布时间】:2012-03-24 05:55:02
【问题描述】:
我有一个 WCF 服务,其实例上下文模式设置为 PerCall,并使用 wsHttpBinding。编码不佳的客户端能够在不正确释放会话的情况下使用会话(即客户端不会在客户端代理上调用 Close())。通过查看“最大并发会话百分比”性能计数器,我可以看到每个连接都使用了一个会话,并且没有释放它。在正常、行为良好的情况下,会话仅在返回调用结果时使用片刻。
我一直试图找到一种方法让这些不良会话超时并消失,但没有成功。由于它不是一个可靠的会话,因此 RecieveTimeout 和 InactivityTimeout 设置似乎没有任何效果。这是我当前配置的一部分,其中设置了许多超时,但似乎不起作用:
<behaviors>
<serviceBehaviors>
<behavior name="UpdaterBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="MembershipProvider"/>
<serviceCertificate findValue="xxxxxx" x509FindType="FindBySubjectName"/>
</serviceCredentials>
<serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="SqlRoleProvider"/>
<serviceThrottling maxConcurrentCalls="10" maxConcurrentSessions="10" maxConcurrentInstances="10" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="UpdaterBinding" messageEncoding="Mtom" maxReceivedMessageSize="100000000" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:01:00" sendTimeout="00:01:00">
<reliableSession ordered="true" inactivityTimeout="00:01:00"
enabled="false" />
<readerQuotas maxArrayLength="100000000"/>
<security>
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
我可以将 serviceThrottling 数字设置得更高,但这只是暂时隐藏了问题,最终一个坏客户端会用完所有会话。我希望服务器释放任何存在超过几分钟的会话,因为没有理由在此服务上的任何内容都需要这么长时间。
有什么建议吗?
【问题讨论】:
标签: wcf