Multiple deployment with jgroup request re-login

I follow the document to configure Interaction sharing user session between two same app in different docker container, for implementation that user can use the app in two URL in one time log-in.
here are two buildWar config for app and app2:
app

task buildWar(type: CubaWarBuilding) {
    includeJdbcDriver = true
    includeContextXml = true
     appProperties = ['cuba.automaticDatabaseUpdate': true,
                     'cuba.cluster.enabled': true,
                     'cuba.webHostName': 'app',
                     'cuba.webPort': '8080',
                     'cuba.dataSourceProvider'     : 'jndi']

app2

task buildWar(type: CubaWarBuilding) {
    includeJdbcDriver = true
    includeContextXml = true
     appProperties = ['cuba.automaticDatabaseUpdate': true,
                     'cuba.cluster.enabled': true,
                     'cuba.webHostName': 'app2',
                     'cuba.webPort': '8080',
                     'cuba.dataSourceProvider'     : 'jndi']

app docker port map 8888:8080
app2 docker port map 9999:8080
they use the same jgroups.xml file copying from cuba-core module without any modification
the log comes from app:

16:37:10.040 INFO  c.h.cuba.core.app.ClusterManager        - Starting cluster
16:37:10.041 INFO  c.h.cuba.core.app.ClusterManager        - Property 'cuba.cluster.jgroupsConfig' is not specified, using jgroups.xml
16:37:10.403 WARN  org.jgroups.stack.Configurator          - JGRP000014: GMS.view_bundling has been deprecated: view bundling is enabled by default
16:37:10.452 WARN  org.jgroups.protocols.UDP               - JGRP000015: the receive buffer of socket MulticastSocket was set to 500.00KB, but the OS only allocated 212.99KB

-------------------------------------------------------------------
GMS: address=7ca780c946f3-36514, cluster=cubaCluster, physical address=172.18.0.3:33781
-------------------------------------------------------------------
16:37:13.498 INFO  c.h.cuba.core.app.ClusterManager        - New cluster view: [7ca780c946f3-36514|0] (1) [7ca780c946f3-36514]
16:37:13.498 INFO  c.h.cuba.core.app.ClusterManager        - Receiving cluster state...
16:37:13.887 INFO  c.h.c.c.sys.dbupdate.DbUpdaterEngine    - Updating data store [Main] ...
16:37:14.029 INFO  c.h.c.c.sys.dbupdate.DbUpdaterEngine    - Data store [Main] is up-to-date
16:37:14.659 INFO  c.h.cuba.core.app.ConfigStorage         - Loading DB-stored app properties cache
16:37:15.394 INFO  c.h.c.s.a.AuthenticationManagerBean     - Logged in: f987b3cf-4f31-a7c6-7e50-3f5bb14c115b [anonymous]
16:37:15.396 INFO  c.h.c.c.s.AbstractWebAppContextLoader   - AppContext started
16:37:15.567 INFO  c.h.c.c.sys.remoting.RemotingServlet    - Initializing Servlet 'remoting'
16:37:15.648 INFO  c.h.c.c.s.r.RemoteServicesBeanCreator   - Configuring remote services
16:37:16.222 INFO  c.h.c.c.sys.remoting.RemotingServlet    - Completed initialization in 655 ms
16:37:16.224 INFO  c.h.c.w.s.s.SingleAppWebServletListener - Single WAR web initializing, servlet context path: /app
16:37:16.250 INFO  c.h.cuba.core.app.ClusterManager        - New cluster view: [7ca780c946f3-36514|1] (2) [7ca780c946f3-36514, ea270997bd91-48145]
16:37:16.264 INFO  c.h.c.c.s.AbstractWebAppContextLoader   - Initializing 'web' block, servlet context path: /app
16:37:16.281 INFO  c.h.cuba.core.sys.AppComponents         - Using app components: [com.haulmont.cuba]
16:37:16.294 INFO  c.h.c.c.s.AbstractWebAppContextLoader   - Loading app properties from classpath:com/company/cubatest/web-app.properties
16:37:16.297 INFO  c.h.c.c.s.AbstractWebAppContextLoader   - Loading app properties from /WEB-INF/local.app.properties
16:37:16.299 INFO  c.h.c.c.s.AbstractWebAppContextLoader   - cuba.webContextName: app
16:37:16.306 INFO  c.h.c.c.s.e.EnvironmentChecksRunner     - Environment checks on web module completed successfully
16:37:18.753 INFO  c.h.c.c.s.r.d.StaticServerSelector      - Server URLs: [http://localhost:8080/app-core/remoting]

the log comes from app2:

16:37:09.456 INFO  c.h.cuba.core.app.ClusterManager        - Starting cluster
16:37:09.457 INFO  c.h.cuba.core.app.ClusterManager        - Property 'cuba.cluster.jgroupsConfig' is not specified, using jgroups.xml
16:37:09.881 WARN  org.jgroups.stack.Configurator          - JGRP000014: GMS.view_bundling has been deprecated: view bundling is enabled by default
16:37:09.957 WARN  org.jgroups.protocols.UDP               - JGRP000015: the receive buffer of socket MulticastSocket was set to 500.00KB, but the OS only allocated 212.99KB

-------------------------------------------------------------------
GMS: address=ea270997bd91-48145, cluster=cubaCluster, physical address=172.18.0.4:52295
-------------------------------------------------------------------
16:37:16.292 INFO  c.h.cuba.core.app.ClusterManager        - New cluster view: [7ca780c946f3-36514|1] (2) [7ca780c946f3-36514, ea270997bd91-48145]
16:37:16.295 INFO  c.h.cuba.core.app.ClusterManager        - Receiving cluster state...
16:37:18.200 INFO  c.h.cuba.core.app.ConfigStorage         - Loading DB-stored app properties cache
16:37:19.405 INFO  c.h.c.s.a.AuthenticationManagerBean     - Logged in: e57fb613-78f0-6c07-0062-55d9066516b0 [anonymous]
16:37:19.413 INFO  c.h.c.c.s.AbstractWebAppContextLoader   - AppContext started
16:37:19.780 INFO  c.h.c.c.sys.remoting.RemotingServlet    - Initializing Servlet 'remoting'
16:37:19.989 INFO  c.h.c.c.s.r.RemoteServicesBeanCreator   - Configuring remote services
16:37:20.772 INFO  c.h.c.c.sys.remoting.RemotingServlet    - Completed initialization in 992 ms
16:37:20.776 INFO  c.h.c.w.s.s.SingleAppWebServletListener - Single WAR web initializing, servlet context path: /app
16:37:20.813 INFO  c.h.c.c.s.AbstractWebAppContextLoader   - Initializing 'web' block, servlet context path: /app
16:37:20.830 INFO  c.h.cuba.core.sys.AppComponents         - Using app components: [com.haulmont.cuba]
16:37:20.842 INFO  c.h.c.c.s.AbstractWebAppContextLoader   - Loading app properties from classpath:com/company/cubatest/web-app.properties
16:37:20.845 INFO  c.h.c.c.s.AbstractWebAppContextLoader   - Loading app properties from /WEB-INF/local.app.properties
16:37:20.847 INFO  c.h.c.c.s.AbstractWebAppContextLoader   - cuba.webContextName: app
16:37:20.855 INFO  c.h.c.c.s.e.EnvironmentChecksRunner     - Environment checks on web module completed successfully
16:37:23.674 INFO  c.h.c.c.s.r.d.StaticServerSelector      - Server URLs: [http://localhost:8080/app-core/remoting]

bui after I loggined in localhost:8888/app returning to another browser tab localhost:9999/app, the 9999 page shows session expired, need login again, when I loggined in 9999 then the 8888 serveer shows it is session expired

Hi,

My guess is that app server cookies are mixed up. There was a similar issue for the Vaadin framework. You can try to fix it by setting up a reverse proxy / balancer in front of the applications, it is a recommended way for clustering the app. There is a doc describing this. I guess you can add it to your docker compose configuration.

thx very much for your reply, I debugged the cookie using the Firefox debugger confirming that they mixed up the session cookies(same session name with different session value), I solved it by sending same cookie(same session name and same session value) to the server.

1 Like