基础安全会话在可靠会话完全完成之前出错,可靠会话出错。
作者:C/S框架网  发布日期:2012/03/02 21:17:59
  基础安全会话在可靠会话完全完成之前出错,可靠会话出错。


WCF建立了可靠会话wsHttpBinding,设闲置时间为4小时,下面是服务端的Web.Config和客户端的App.Config文件内reliableSession 参数设置:



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



reliableSession.enable=True,启用可靠会话,但在10分钟后再次在界面上操作,程序出错:


贴图图片

意思大致为:可靠会话进程尚末结束,但基础安全会话出现错误,有可能是超时导致断掉基础安全会话。

根据这条思路,可以确定是某个配置出现的问题,仔细检查Web.Config和App.Config文件发现receiveTimeout属性,receiveTimeout属性注释如下:


//Gets or sets the interval of time that a connection can remain inactive,
//during which no application messages are received, before it is dropped.
//
//译:获取或设置服务在非活动期间的超时值,在此期间如未产生过数据通信,服务会自动断线。
//

public TimeSpan ReceiveTimeout { get; set; }




解决方案

修改receiveTimeout属性的值,将超时时间改大点,建议改为4或8小时(通常上/下午工作时间小于4小时,改为4最理想),下面是Config文件的配置。


<binding name="ISalesModuleService" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text"  receiveTimeout="04:00:00"  >


 <!--大数据量通信设置-->
         
<
readerQuotas maxDepth="6553600" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="6553600" maxNameTableCharCount="6553600"/>


 <!--可靠会话设置-->
         
<
reliableSession ordered="true" inactivityTimeout="04:00:00" enabled="true" />

</binding>



 

参考文章:


WCF App.Config 配置参数详解:OpenTimeout, CloseTimeout, SendTimeout, ReceiveTimeout
http://www.csframework.com/archive/5/arc-5-20120302-1892.htm


WCF 可靠性会话(reliableSession)中的inactivityTimeout和receiveTimeout 测试报告
http://www.csframework.com/archive/5/arc-5-20120302-1893.htm

上一篇 下一篇