WCF闲置超时WCF

2023-09-03 01:43:11 作者:何日不离伤

我创建了一个非常简单的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.

然而,当我改变我的app.config从

However, when I change my app.config from

 <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在   EndpointDispatcher。这可能是因为一个合同的不匹配   (发送者和接收者之间不匹配的操作)或结合/安全   在发送器和接收器之间的失配。检查发件人和   接收器具有相同的合同,相同的绑定(包括   安全性要求,例如信息,运输,无)。的

The message with Action 'http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

这是我的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.