管理同一台计算机上 Play 框架服务器的多个实例的会话详细信息

发布于 2025-01-03 23:41:08 字数 504 浏览 3 评论 0原文

我一直在开发 Play 框架社交网络应用程序,在实际尝试测试该应用程序时遇到了一个小问题。我正在使用在不同端口上运行的同一应用程序的多个实例,但其中一个实例的会话信息被另一个实例覆盖。

例如,如果我在会话的一个实例上为 Bob 创建一个帐户,然后在第二个会话(在完全不同的端口上)上加载主页,我会发现 Bob 已经登录。为 Alice 创建帐户会导致 Bob丢失所有会话数据,取而代之的是 Alice 的新数据。

我的代码非常简单:

    static boolean authenticate(String username, String password) {
        User u = User.connect(username,password);
        return (u != null);
    }

其中一个应用程序在端口 9001 上运行,另一个应用程序在端口 9002 上运行。

有谁知道如何解决此问题并从同一台计算机测试多个用户帐户?

I've been working on a Play framework social networking application, and I've come across a small problem when actually attempting to test the application. I'm using multiple instances of the same application running on different ports, but the session information from one is being overwritten by the other.

For example, should I create an account for Bob on one instance of the session and then load the homepage on the second session (on a completely different port), I find that Bob is already logged in. Creating an account for Alice causes Bob to lose all his session data in favour of Alice's new data.

The code that I have is quite simple:

    static boolean authenticate(String username, String password) {
        User u = User.connect(username,password);
        return (u != null);
    }

One of the apps is running on port 9001 and the other on port 9002.

Does anyone have any idea how I can work around this issue and test multiple user accounts from the same computer?

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

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

发布评论

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

评论(1

夏见 2025-01-10 23:41:08

考虑以下几点:

  1. 您是否使用相同的浏览器实例进行测试?如果您使用不同的浏览器登录不同的播放实例怎么办?

  2. 启动2个游戏实例的动机是什么?您是否正在尝试设置负载平衡或容错解决方案,或者您实际上需要 2 个不同的服务器?对于后一种情况,您应该使用“play Secret”生成不同的秘密种子

Think about the following points:

  1. Are you testing using the same browser instance? What if you login to different play instance using different browser?

  2. What's the motivation to start 2 play instance? Are you trying to setup a load balance or fault tolerant solution or you actually need to 2 different server? For the latter case, you should generate different secret seeds using "play secret"

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