# Discourse 成员被登出——如何解决？

**URL:** <https://meta.discourse.org/t/discourse-members-being-logged-out-how-to-fix/152514>\
**Category:** Support\
**Created:** [2020年五月24日 10:46 UTC](https://meta.discourse.org/t/discourse-members-being-logged-out-how-to-fix/152514 "2020-05-24T10:46:48Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![pnoeric](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pnoeric/32/177144_2.png) [@pnoeric](https://meta.discourse.org/u/pnoeric)\
**Post date:** [2020年五月24日 11:18 UTC](https://meta.discourse.org/t/discourse-members-being-logged-out-how-to-fix/152514/7 "2020-05-24T11:18:17Z")

</div>

嗯。当用户使用论坛并阅读话题等时，如果他们执行了某个会触发操作的行为（如 create\_post、create\_topic、edit\_post 等），我就会通过 webhook 收到一条消息。这会通知主站该用户仍处于活跃状态，从而我可以更新其会话的“最后点击时间”值，防止其被登出。这本来应该是正确的，一切正常。

然而，如果某个成员只是长时间阅读消息……他们的 Discourse 空闲时间确实会在每次操作时被重置（这很好），但_我的主站从未收到任何 webhook 消息_来表明该用户是活跃的。因此，如果超过 1 小时没有任何活动（看起来像是他们去了论坛却离开了电脑），主站就会认为他们已离线并将其登出。

这似乎存在逻辑漏洞。对于正确的 SSO 实现，Discourse 是否应该有一种方式可以告知我用户的会话是否活跃（即使他们只是在阅读）？也许 Discourse 应该在用户活跃但未触发其他 webhook 消息时，每隔 5 分钟发送一次心跳检测。

或者，当我的站点认为用户已超时，我是否可以调用 Discourse 来询问该用户在其平台上是否仍活跃？有没有这样的方法？（我注意到 [https://meta.discourse.org/t/is-there-an-endpoint-to-check-if-a-user-is-logged-in/72780/3，但我不太确定那是否正是我需要的，而且](https://meta.discourse.org/t/is-there-an-endpoint-to-check-if-a-user-is-logged-in/72780/3%EF%BC%8C%E4%BD%86%E6%88%91%E4%B8%8D%E5%A4%AA%E7%A1%AE%E5%AE%9A%E9%82%A3%E6%98%AF%E5%90%A6%E6%AD%A3%E6%98%AF%E6%88%91%E9%9C%80%E8%A6%81%E7%9A%84%EF%BC%8C%E8%80%8C%E4%B8%94) `/session/current.json` 并未出现在 API 文档中。）不过，这样做会产生大量的 API 调用——我的站点每分钟因不活跃而登出约 15-20 个用户，这意味着需要为每个用户发起调用（如果我没有缓存他们的 Discourse ID，甚至可能需要多次调用）。

朋友们，你们怎么看或有什么建议？

---

_[View the full topic](https://meta.discourse.org/t/discourse-members-being-logged-out-how-to-fix/152514)._
