【问题标题】:Session timeout differences会话超时差异
【发布时间】:2014-01-09 13:22:32
【问题描述】:

我正在为一个相当大的项目提供一些支持。我的任务是将会话超时更改为比现在更长的时间。现在他们在大约 10 分钟左右后注销。我发现了很多不同的东西,我需要一些帮助来弄清楚它们都做了什么。

首先我得到了这个:

 <sessionState mode="InProc" timeout="240" cookieless="UseCookies" />

这是在 240 分钟后触发的,所以不可能是这个。 然后我得到了这个:

  <binding name="WSHttpBinding_IFootprintService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:00:01" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <reliableSession ordered="true" inactivityTimeout="00:00:01" enabled="false" />
      <security mode="Message">
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
      </security>
    </binding>
    <binding name="AdministrationEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:00:01" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <reliableSession ordered="true" inactivityTimeout="00:00:01" enabled="false" />
      <security mode="Message">
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
      </security>
    </binding>
    <binding name="ProductionEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:00:01" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <reliableSession ordered="true" inactivityTimeout="00:00:01" enabled="false" />
      <security mode="Message">
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
      </security>

在那段代码中,我可以做很多不同的事情。我就是想不通 closeTimeout、openTimeout、receiveTimeout、sendTimeout、inactivitytimeout 和 sessionstate timeout 之间有什么区别?

【问题讨论】:

    标签: c# asp.net wcf session timeout


    【解决方案1】:

    借用@marc_s 在this question的回复

    最重要的是sendTimeout,它表示客户端需要多长时间 将等待 WCF 服务的响应。您可以指定 您的设置中的小时:分钟:秒 - 在我的示例中,我设置了 超时到 25 分钟。

    openTimeout 顾名思义就是你的时间量 当您打开与 WCF 服务的连接时愿意等待。 同样,closeTimeout 是您关闭 您将等待的连接(处置客户端代理) 抛出异常。

    receiveTimeout 有点像 sendTimeout 的镜子 - 而 sendTimeout 是您等待来自 服务器,receiveTimeout 是你给你的时间量 客户端接收和处理来自服务器的响应。

    如果您来回发送“正常”消息,两者都可以 很短——尤其是 receiveTimeout,因为收到了 SOAP 消息,解密,检查和反序列化几乎需要 没时间。流媒体的故事不同 - 在这种情况下,您 客户端可能需要更多时间才能真正完成“下载” 从服务器返回的流。

    希望对你有帮助,

    【讨论】:

    • 所以没有一个让用户自动注销?我知道这样做: 但它必须是其他使用户注销的东西:/ 因为这需要用户 4 小时才能注销?
    • 应该是inactivityTimeout导致用户注销。
    • 用户登录需要超过 1 分钟。也许如果触发了sendtimeout,它会触发下一个超时,这样所有超时的添加超时就是用户注销所需的时间?
    • 不,我不认为它是这样工作的,注意所有的超时都描述了独立的事件。
    【解决方案2】:

    希望本站对您有所帮助http://msdn.microsoft.com/en-us/library/hh924831(v=vs.110).aspx 关于超时的快速总结:

    在客户端:
    SendTimeout – 用于初始化 OperationTimeout,它控制发送消息的整个过程,包括接收请求/回复服务操作的回复消息。当从回调合约方法发送回复消息时,此超时也适用。

    OpenTimeout – 在未指定明确超时值时打开通道时使用

    CloseTimeout – 在未指定明确超时值时关闭通道时使用

    ReceiveTimeout - 不使用客户端超时

    在服务方面:
    SendTimeout、OpentTimeout、CloseTimeout 和客户端一样

    ReceiveTimeout – 服务框架层使用它来初始化会话空闲超时,该超时控制会话在超时之前可以空闲多长时间。

    另见这篇关于 WCF 会话超时WCF Session Timeout的帖子

    【讨论】:

      猜你喜欢
      • 2011-06-22
      • 2014-11-10
      • 1970-01-01
      • 2010-12-05
      • 2010-12-25
      相关资源
      最近更新 更多