WCF 不活动超时 [英] WCF inactivity timeout

查看:24
本文介绍了WCF 不活动超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个非常简单的 WCF 服务,托管在 Windows 服务上,紧跟 MSDN 上的示例:http://msdn.microsoft.com/en-us/library/ff649818.aspx

I have created a very simple WCF service, hosted on windows service, closely following the example on MSDN here: http://msdn.microsoft.com/en-us/library/ff649818.aspx

如果我在第一次调用后 10 分钟后第二次调用我的服务,我会收到不活动超时错误.我了解这是 WCF 客户端的默认设置.

If I make a 2nd call to my service > 10 mins after my first call, I'll get a inactivity timeout error. I understand that this is the default setting of the WCF client.

但是,当我从

 <reliableSession ordered="true" inactivityTimeout="00:10:00"
                   enabled="false" />

 <reliableSession ordered="true" inactivityTimeout="infinite"
                    enabled="true" />

尝试拨打电话时出现此错误:

I get this error when I try to make a call:

带有操作的消息'http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence' 不能由于 ContractFilter 在接收端不匹配,在接收端处理端点调度程序.这可能是因为合同不匹配(发送方和接收方之间不匹配的操作)或绑定/安全发送方和接收方不匹配.检查发件人和接收者具有相同的合同和相同的绑定(包括安全要求,例如消息,传输,无).

这就是我的 WCF 配置文件在 windows 服务上的样子.

This is how my WCF config file look like on the windows service.

  <system.serviceModel>
<services>
  <service name="Asis.IBSS.Milestone.WCFService.ServiceImplementation.VideoService">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract="Asis.IBSS.Milestone.WCFService.ServiceContract.IVideoService">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:8555/MilestoneService"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="false"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

我的问题是,如何将 inactivityTimeout 设置为 inifinte,并避免出现错误?

My question would be, how do I set the inactivityTimeout to inifinte, and circumvent the errors I'm getting?

推荐答案

我认为您还需要将绑定上的 receiveTimeout 设置为无限.这两个属性,receiveTimeout 和 inactivityTimeout 彼此有一些依赖关系,如果您将 inactivityTimeout 设置为比 receiveTimeout 更高的值,您可能会得到一些错误.

I think that you need to set also the receiveTimeout on the binding to infinite. This two properties, receiveTimeout and inactivityTimeout have some dependencies on each other, if you set the inactivityTimeout to a higher value than the receiveTimeout you might get some errors.

例如:

        <bindings>
        <wsFederationHttpBinding>
    <binding name="someServiceFederatedBinding" maxReceivedMessageSize="2147483647" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    </binding>
        </wsFederationHttpBinding>
    </bindings>

并将 bindingConfiguration="someServiceFederatedBinding" 放入您的服务中.

and put bindingConfiguration="someServiceFederatedBinding" in your service.

这篇关于WCF 不活动超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆