gpt4 book ai didi

c# - WCF 不活动超时

转载 作者:行者123 更新时间:2023-11-30 16:23:05 25 4
gpt4 key购买 nike

我创建了一个非常简单的 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,并避免我遇到的错误?

最佳答案

我认为您还需要将绑定(bind)的 receiveTimeout 设置为无限。 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"放入您的服务中。

关于c# - WCF 不活动超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11946117/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com