为什么在 StateServer 模式下运行时会丢失会话?

发布于 2024-08-30 04:22:35 字数 724 浏览 2 评论 0原文

我已检查服务器 (Win Server 2003) 应用程序事件日志是否存在以下问题 http://support.microsoft .com/kb/308097 未显示。看起来会话对于随机用户是随机下降的

这是一个单一的服务器设置,没有网络场,也没有负载平衡

即使我上面指出的问题没有出现在日志中,是否值得增加 stateNetworkTimeout 属性?目前的配置很简单

<sessionState mode="StateServer" cookieless="false" stateConnectionString="tcpip=localhost:42424" timeout="60"/>

更新:

使用 FormsAuth 并将超时设置为 60

IIS6 设置

  1. 回收工作进程(以分钟为单位)= 120
  2. 回收工作进程(请求数)= 35000
  3. 回收工作进程位于以下次数 = 未选中
  4. 最大虚拟内存 = 未选中
  5. 最大已用内存 = 未选中
  6. 空闲后关闭工作进程 = 90
  7. 限制内核请求队列 = 1500
  8. 其他一切 = 未选中

I have checked the servers (Win Server 2003) application event logs for the following problem http://support.microsoft.com/kb/308097 which doesn't show up. It just appears that sessions drop randomly for random users

It's a single server setup, no web farms and no load balancing

Even though the issue I point to above doesn't occur in the logs, is it worth increasing the stateNetworkTimeout attribute anyway? The configuration at the moment is simply

<sessionState mode="StateServer" cookieless="false" stateConnectionString="tcpip=localhost:42424" timeout="60"/>

UPDATES:

Using FormsAuth and the Timeout is set to 60

IIS6 Settings

  1. Recycle worker processes (in minutes) = 120
  2. Recycle worker processes (number of requests) = 35000
  3. Recycle worker processes at the following times = Unchecked
  4. Maximum virtual memory = Unchecked
  5. Maximum used memory = Unchecked
  6. Shutdown worker processes after being idle = 90
  7. Limit the kernel request queue = 1500
  8. Everthing else = Unchecked

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

狼性发作 2024-09-06 04:22:35

我意识到这是一个较老的问题,但我最近遇到了类似的问题。就我而言,额外的日志记录显示会话变量在一系列 .aspx 页面中似乎随机丢失。

在偶然发现这篇博客文章后,我检查了我的代码并果然,我所有的 Response.Redirect 语句要么是默认的(例如 Response.Redirect(target) ,要么是 true (例如 Response.Redirect(target, true) ))。在明智地审查我的重定向并设置之后的重定向之后将 Session 变量设置为 false (例如 Response.Redirect(target, false) )——问题[似乎]已解决!我注意到,执行此操作时需要小心,因为页面的其余部分仍将在重定向后执行!在许多情况下,我需要在重定向后添加一个 return 语句,以防止在重定向后运行我不打算运行的代码,

我只在生产中和负载下遇到过丢失会话变量的情况(从未在开发或加载中) 。我关于为什么这解决了我的问题的理论是 Response.Redirect (默认/true)强制结束执行线程 - 如果线程仍然忙于序列化会话对象并将它们放回状态服务器(当它时)。线程)被中断,它们(会话对象)可能会丢失。

I realize this is an older question, but I recently experienced a similar issue. In my case, additional logging revealed that Session variables were being lost seemingly at random across a series of .aspx pages.

After stumbling upon this blog post I reviewed my code and sure enough, all of my Response.Redirect statements were either the default (e.g. Response.Redirect(target), or true (e.g. Response.Redirect(target, true) ). After judiciously reviewing my redirects and setting the ones that came after the setting of Session variables to false (e.g. Response.Redirect(target, false) ) -- problem [seemingly] solved! I would note that you need to be careful when doing this as the rest of the page will still execute after the redirect when passing false. In many cases I needed to add a return statement just after the redirect to prevent running code that I didn't intend to run after the redirect.

I only experienced lost session variables in production, and under load (never in development or testing). My theory on why this solved my problem is that Response.Redirect (default/true) forcibly ends the executing thread -- if the thread is still busy working serializing the session objects and placing them back into the state server when it (the thread) is interrupted, they (the session objects) can be lost.

北凤男飞 2024-09-06 04:22:35

您还需要在表单身份验证部分设置超时(默认为 30 分钟)

http://weblogs.asp.net/scottgu/archive/2005/11/08/430011.aspx

you also need to set the timeout in forms authentication section (30 min by default)

http://weblogs.asp.net/scottgu/archive/2005/11/08/430011.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文