ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

c#-WCF不活动超时

2019-11-27 21:07:45  阅读:363  来源: 互联网

标签:app-config wcf c net


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

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有