简体   繁体   English

Hazelcast HTTP 会话复制不会复制任何内容

[英]Hazelcast HTTP session replication doesn't replicate anything

i've some problems with hazelcast http session replication feature.我在hazelcast http 会话复制功能上遇到了一些问题。

I'm trying to deploy a web application with hazelcast http session replication in a pair of tomcat 7.0.54 already in cluster (SimpleTcpCluster with a DeltaManager), running under java 1.7.0_25 with others non-hazelcast clustered applications.我正在尝试在集群中的一对 tomcat 7.0.54(带有 DeltaManager 的 SimpleTcpCluster)中部署一个带有 hazelcast http 会话复制的 web 应用程序,在 java 1.7.0_25 下与其他非 hazelcast 集群应用程序一起运行。

i've some questions:我有一些问题:

  • is it possible to have hazelcast clsutered and non-hazelcast clsutered application in the same tomcat cluster?是否可以在同一个 tomcat 集群中使用 hazelcast clsutered 和 non-hazelcast clsutered 应用程序?
  • the application with hazelcast should be distributable?带有hazelcast 的应用程序应该是可分发的吗? (by adding in it's web.xml like the others) (通过像其他人一样添加它的 web.xml )
  • the tomcat's in which the app is deployed shouldn't be in cluster?部署应用程序的 tomcat 不应该在集群中? can i have other application clusterized with standard tomcat session replication in the same tomcat?我可以在同一个 tomcat 中使用标准 tomcat 会话复制对其他应用程序进行集群吗?

EDIT:编辑:

More detailed explanation of what i'm doing:更详细的解释我在做什么:

i'm trying to create a simple web app, with just one servlet that, at the first user request generate one new http session, and than, for each GET request will print the session id.我正在尝试创建一个简单的 web 应用程序,只有一个 servlet,在第一个用户请求时生成一个新的 http 会话,然后对于每个 GET 请求将打印会话 ID。 this is the servlet code:这是servlet代码:

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    System.out.println("Get Method. Check Session...");
    HttpSession session = req.getSession(false);
    if (session==null) {
        System.out.println("User with null session, generating one...");
        session = req.getSession(true);
        if (session==null)
            System.out.println("Session can not be generated.");
    }
    if (session!=null)
        System.out.println("Received GET request from session " + session.getId());
}

In order to introduce the hazelcast WM to get the session replicated among 2 tomcats, i've added to my project:为了引入 hazelcast WM 以在 2 个 tomcat 之间复制会话,我已将其添加到我的项目中:

  • hazelcast-3.2.5.jar into WEB-INF folder hazelcast-3.2.5.jar 到 WEB-INF 文件夹

  • hazelcast-wm-3.2.5.jar into WEB-INF folder hazelcast-wm-3.2.5.jar 到 WEB-INF 文件夹

  • standard hazelcast.xml into WEB-INF folder (exacly the same hazelcast.xml that is packaged within the ZIP archive of the hazelcast 3.2.5, into the bin folder)将标准 hazelcast.xml 放入 WEB-INF 文件夹(与打包在 hazelcast 3.2.5 的 ZIP 存档中的 hazelcast.xml 完全相同,放入 bin 文件夹中)

  • added the hazelcast filter to my web.xml, exacly the same in the example in the official documentation将hazelcast过滤器添加到我的web.xml中,与官方文档中的示例完全相同

On the official documentation i didn't find any other configuration needed ( http://hazelcast.org/docs/latest/manual/html/httpsessionclustering.html ), and i met all requirements.在官方文档中,我没有发现需要任何其他配置( http://hazelcast.org/docs/latest/manual/html/httpsessionclustering.html ),并且我满足了所有要求。

In front of both tomcats i have an HAproxy that balance the traffic (with stiky-session) between both nodes.在两个 tomcat 前面,我有一个 HAproxy 来平衡两个节点之间的流量(使用 stiky-session)。

When both nodes start they join the cluster, and i have this log on both sides:当两个节点都启动时,它们会加入集群,并且双方都有这个日志:

INFO: [192.168.0.68]:4701 [dev] [3.2.5]
Members [2] {
    Member [192.168.0.68]:4701 this
    Member [192.168.0.49]:4701
}

When i made the first request, i got, on the first node, this logs: Get Method.当我发出第一个请求时,我在第一个节点上得到了这个日志:Get Method。 Check Session... User with null session, generating one... Received GET request from session HZ2F779DFA402A406E9ACCA3E0298B37F5检查会话...用户为空会话,生成一个...收到来自会话 HZ2F779DFA402A406E9ACCA3E0298B37F5 的 GET 请求

and each request after this one generate this logs:并且在此之后的每个请求都会生成此日志:

Get Method.获取方法。 Check Session...检查会话...

Received GET request from session HZ2F779DFA402A406E9ACCA3E0298B37F5收到来自会话 HZ2F779DFA402A406E9ACCA3E0298B37F5 的 GET 请求

When i KILL this tomcat, the HAProxy start to send all request to the second one and i expected that the session will be the same (HZ2F779DFA402A406E9ACCA3E0298B37F5) but i got this logs:当我杀死这个 tomcat 时,HAProxy 开始将所有请求发送到第二个,我预计会话将是相同的(HZ2F779DFA402A406E9ACCA3E0298B37F5),但我得到了这个日志:

Get Method.获取方法。 Check Session...检查会话...

User with null session, generating one...具有空会话的用户,生成一个...

Received GET request from session HZB89D6CDC1CC94FDEBC82019BAAA9022E收到来自会话 HZB89D6CDC1CC94FDEBC82019BAAA9022E 的 GET 请求

Get Method.获取方法。 Check Session...检查会话...

Received GET request from session HZB89D6CDC1CC94FDEBC82019BAAA9022E收到来自会话 HZB89D6CDC1CC94FDEBC82019BAAA9022E 的 GET 请求

why the session is changed?为什么会话被改变? what i'm doing wrong?我做错了什么?

this use case is so simple that probably i'm missing something, but i can't figure it out.这个用例非常简单,可能我遗漏了一些东西,但我无法弄清楚。 there are others pre-requisite?还有其他先决条件吗?

SOFTWARE USED:使用的软件:

hazelcast 3.2.5榛铸 3.2.5

tomcat 7.0.54 Tomcat 7.0.54

java 1.7.0_25 Java 1.7.0_25

Can you post some logging, especially something that looks like this:你能发布一些日志,特别是像这样的东西:

Members [2] {
    Member [192.168.1.100]:5701 this
    Member [192.168.1.100]:5702
}

About your questions:关于您的问题:

  • is it possible to have hazelcast clsutered and non-hazelcast clsutered application in the same tomcat cluster?是否可以在同一个 tomcat 集群中使用 hazelcast clsutered 和 non-hazelcast clsutered 应用程序?

That should not be a problem.那应该不是问题。

  • the application with hazelcast should be distributable?带有hazelcast 的应用程序应该是可分发的吗? (by adding in it's web.xml like the others) (通过像其他人一样添加它的 web.xml )

What do you mean with distributable?可分发是什么意思?

  • the tomcat's in which the app is deployed shouldn't be in cluster?部署应用程序的 tomcat 不应该在集群中? can i have other application clusterized with standard tomcat session replication in the same tomcat?我可以在同一个 tomcat 中使用标准 tomcat 会话复制对其他应用程序进行集群吗?

I don't think that should be a problem as long as there are no port conflicts.只要没有端口冲突,我认为这应该不是问题。

Could you please make sure sticky-session is true in hazelcast configurations?您能否确保在hazelcast 配置中粘性会话是正确的?

Please follow the steps mentioned athttps://github.com/hazelcast/hazelcast-wm#using-sticky-sessions请按照https://github.com/hazelcast/hazelcast-wm#using-sticky-sessions 中提到的步骤操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM