我已经创建了一个Web服务。在一段时间后,我最终得到以下错误:“打开操作未在分配的00:01:00超时内完成。分配给此操作的时间可能是一部分更长的超时时间。“
我不确定为什么我收到此错误,因为我已将开启超时设置为大约2小时。我是WCF Web服务和Web服务的新手。我在下面显示的配置是否有红色标志?
.NET版本:4.0
客户端配置:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="SecurityServiceDev" receiveTimeout="02:00:00" openTimeout="02:00:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxConnections="1000" maxBufferSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<diagnostics>
<messageLogging logEntireMessage="true" maxMessagesToLog="300" logMessagesAtServiceLevel="true" logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<client>
<endpoint address="net.tcp://XXX.svc" binding="netTcpBinding" bindingConfiguration="SecurityServiceDev" contract="SecurityProxy.ISecurityService" name="SecurityService" />
</client>
网络服务配置:
<system.serviceModel>
<services>
<service name="TMS.DAL.Common.Security.BAL.SecurityService" behaviorConfiguration="DataServiceBehavior">
<endpoint address="net.tcp://XXX.svc"
name="SecurityService"
binding="netTcpBinding"
bindingConfiguration="Binding"
contract="TMS.DAL.Common.Security.BAL.ISecurityService"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="Binding"
receiveTimeout="02:00:00"
openTimeout="02:00:00"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxConnections="1000"
maxBufferSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<client/>
<behaviors>
<serviceBehaviors>
<behavior name="DataServiceBehavior" >
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="61200000" />
<serviceThrottling maxConcurrentCalls="1000"
maxConcurrentInstances="2147483647" maxConcurrentSessions="1000"/>
</behavior>
</serviceBehaviors>
</behaviors>
代码中唯一的配置如下:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]
public class SecurityService : ISecurityService
服务合同:
[ServiceContract]
public interface ISecurityService
{
[OperationContract]
bool IsUserInRole(String userName, String roleName);
[OperationContract]
bool DoesUserHavePermission(String userName, String permissionName);
[OperationContract]
List<String> GetUsersInRole(String roleName);
[OperationContract]
List<String> GetRolesForUser(String userName);
[OperationContract]
List<String> GetPermissionsForUser(String userName);
[OperationContract]
List<String> GetPermissionsForRole(String roleName);
[OperationContract]
List<String> GetRolesForApplication(String appName);
[OperationContract(Name = "GetListValuesForRoleAndList")]
List<String> GetListValues(String roleName, String listNames);
[OperationContract(Name = "GetListValuesForRolesAndList")]
List<String> GetListValues(List<String> roleNames, List<String> listNames);
[OperationContract(Name = "GetListValuesForAppUserList")]
List<String> GetListValues(String appName, String userName, List<String> listNames);
[OperationContract]
List<String> GetListsForUser(String userName);
[OperationContract]
bool RoleExists(String roleName);
[OperationContract]
bool ExternalUserExists(String userName, String password);
答案 0 :(得分:2)
每个页面都会为请求重新创建然后被丢弃 - NetTcpBinding本质上是会话的,这意味着它会保留资源,直到客户端说他们不再需要它们或者客户端消失,在您的情况下,您需要2小时将receiveTimeout设置为2小时。
因为你没有调用Close
WCF认为会话仍处于活动状态,因此会限制来自新页面的请求,直到旧会话开始超时。 .NET 4默认会话限制相当高(100 x内核数)并且您已将其自己设置为1000,因此在处理运行一段时间之前您不会看到此问题。在某些方面,.NET 3.5中的默认会话限制在10处更好,因为如果您遇到的情况很快就会非常明显
我写了一段关于会议的blog post