编程语言
首页 > 编程语言> > c#-WCF不活动超时

c#-WCF不活动超时

作者:互联网

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

如果我第二次致电我的服务>第一次通话10分钟后,我会收到一个不活动超时错误.我知道这是WCF客户端的默认设置.

但是,当我从以下位置更改app.config时

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

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

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

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服务上的样子.

  <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,并规避我收到的错误?

解决方法:

我认为您还需要将绑定上的receiveTimeout设置为infinite.这两个属性receiveTimeout和inactivityTimeout相互依赖,如果将inactivityTimeout设置为比receiveTimeout高的值,则可能会出现一些错误.

例如:

        <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”.

标签:app-config,wcf,c,net
来源: https://codeday.me/bug/20191127/2076911.html