You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lou Henry <lo...@gmail.com> on 2012/09/21 00:02:46 UTC

Sticky sessions not working

I'm running Apache Tomcat 7.0.14 and Apache 2.2.21 (mod_jk1.2.37).  I
am trying to load balance two Tomcat Servers and sticky sessions are
not working.  I am running
a two-factor authentication package and it looks like my LB
configuration is directing the user to one Tomcat for part of the
transaction and to the other Tomcat
server for the other part. When I bring down one of the Tomcat
servers, everything works fine; but with both Tomcat servers up, I get
500 errors.  So, I am trying
to stick the webserver session to one particular Tomcat server.
Listed below is my configuration.  Also, I tried without the domain
directive also.  I am not quite
sure if that's a random name or should it be something specific.

Can someone please assist?  Thank you...

*workers.properties*

worker.list=loadbalancer,status



# Define Node1

# modify the host as your host IP or DNS name.

worker.node1.domain=jvm1

worker.node1.port=xxxx

worker.node1.host=t*****20.xxxxx.xxxx

worker.node1.type=ajp13

worker.node1.lbfactor=1

worker.node1.ping_mode=A



# Define Node2

# modify the host as your host IP or DNS name.

worker.node2.domain=jvm2

worker.node2.port=xxxx

worker.node2.host=t*****21.xxxxx.xxxx

worker.node2.type=ajp13

worker.node2.lbfactor=1

worker.node2.ping_mode=A



# Load-balancing behaviour

worker.loadbalancer.type=lb

worker.loadbalancer.balance_workers=node1,node2

worker.loadbalancer.sticky_session=True



# Status worker for managing load balancer

worker.status.type=status



# Added per Anakam direction 113010

worker.node1.socket_keepalive=True

worker.node1.socket_timeout=300



# Added per Anakam direction 113010

worker.node2.socket_keepalive=True

worker.node2.socket_keepalive=300


*server.xml on Tomcat Node 1*

<Engine name="Catalina" defaultHost="localhost" jvmRoute="node1">

*server.xml on Tomcat Node 2*

<Engine name="Catalina" defaultHost="localhost" jvmRoute="node2">

Re: Sticky sessions not working

Posted by Lou Henry <lo...@gmail.com>.
Thank you all for your responses.  We found that sticky was set up
properly.  The problem was with the application and how it handles
clustering.  Thanks again...

On Fri, Sep 21, 2012 at 11:51 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Nicolas,
>
> On 9/21/12 12:58 AM, Nicolas Sarazin wrote:
> > Add : worker.node1.route=node1
> >
> > And : worker.node2.route=node2
> >
> > To use sticky session. These directives attach name route at the
> > end of JSESSIONID.
>
> That shouldn't be necessary, as the worker's name is the default
> 'route', and the OP has them set up properly.
>
> I think this might be interfering with your setup:
> > Le vendredi 21 septembre 2012, Lou Henry a écrit :
> >
> >> worker.node1.domain=jvm1 worker.node2.domain=jvm2
>
> Lou, do you need the "domain" for anything? The docs say that when
> sticky_session=true (which is the default, and you haven't overridden
> it), then the domain becomes the 'route'. Since you aren't explicitly
> specifying the route, then you are probably getting implicitly:
>
> worker.node1.route=jvm1
> worker.node2.route=jvm2
>
> when what you want is 'node1' and 'node2'.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
>
> iEYEARECAAYFAlBdNa0ACgkQ9CaO5/Lv0PBMFwCfQZdAuuEH+FNiwli6n7+dk22B
> 6/4AoIk1i4MnH3qglv8pah5xY47Jzos+
> =EA2N
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Sticky sessions not working

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nicolas,

On 9/21/12 12:58 AM, Nicolas Sarazin wrote:
> Add : worker.node1.route=node1
> 
> And : worker.node2.route=node2
> 
> To use sticky session. These directives attach name route at the
> end of JSESSIONID.

That shouldn't be necessary, as the worker's name is the default
'route', and the OP has them set up properly.

I think this might be interfering with your setup:
> Le vendredi 21 septembre 2012, Lou Henry a écrit :
> 
>> worker.node1.domain=jvm1 worker.node2.domain=jvm2

Lou, do you need the "domain" for anything? The docs say that when
sticky_session=true (which is the default, and you haven't overridden
it), then the domain becomes the 'route'. Since you aren't explicitly
specifying the route, then you are probably getting implicitly:

worker.node1.route=jvm1
worker.node2.route=jvm2

when what you want is 'node1' and 'node2'.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBdNa0ACgkQ9CaO5/Lv0PBMFwCfQZdAuuEH+FNiwli6n7+dk22B
6/4AoIk1i4MnH3qglv8pah5xY47Jzos+
=EA2N
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Sticky sessions not working

Posted by Nicolas Sarazin <ni...@gmail.com>.
Hello,

Add :

worker.node1.route=node1

And :

worker.node2.route=node2

To use sticky session. These directives attach name route at the end of
JSESSIONID.

Best regards,

Nicolas SARAZIN

Le vendredi 21 septembre 2012, Lou Henry a écrit :

> I'm running Apache Tomcat 7.0.14 and Apache 2.2.21 (mod_jk1.2.37).  I
> am trying to load balance two Tomcat Servers and sticky sessions are
> not working.  I am running
> a two-factor authentication package and it looks like my LB
> configuration is directing the user to one Tomcat for part of the
> transaction and to the other Tomcat
> server for the other part. When I bring down one of the Tomcat
> servers, everything works fine; but with both Tomcat servers up, I get
> 500 errors.  So, I am trying
> to stick the webserver session to one particular Tomcat server.
> Listed below is my configuration.  Also, I tried without the domain
> directive also.  I am not quite
> sure if that's a random name or should it be something specific.
>
> Can someone please assist?  Thank you...
>
> *workers.properties*
>
> worker.list=loadbalancer,status
>
>
>
> # Define Node1
>
> # modify the host as your host IP or DNS name.
>
> worker.node1.domain=jvm1
>
> worker.node1.port=xxxx
>
> worker.node1.host=t*****20.xxxxx.xxxx
>
> worker.node1.type=ajp13
>
> worker.node1.lbfactor=1
>
> worker.node1.ping_mode=A
>
>
>
> # Define Node2
>
> # modify the host as your host IP or DNS name.
>
> worker.node2.domain=jvm2
>
> worker.node2.port=xxxx
>
> worker.node2.host=t*****21.xxxxx.xxxx
>
> worker.node2.type=ajp13
>
> worker.node2.lbfactor=1
>
> worker.node2.ping_mode=A
>
>
>
> # Load-balancing behaviour
>
> worker.loadbalancer.type=lb
>
> worker.loadbalancer.balance_workers=node1,node2
>
> worker.loadbalancer.sticky_session=True
>
>
>
> # Status worker for managing load balancer
>
> worker.status.type=status
>
>
>
> # Added per Anakam direction 113010
>
> worker.node1.socket_keepalive=True
>
> worker.node1.socket_timeout=300
>
>
>
> # Added per Anakam direction 113010
>
> worker.node2.socket_keepalive=True
>
> worker.node2.socket_keepalive=300
>
>
> *server.xml on Tomcat Node 1*
>
> <Engine name="Catalina" defaultHost="localhost" jvmRoute="node1">
>
> *server.xml on Tomcat Node 2*
>
> <Engine name="Catalina" defaultHost="localhost" jvmRoute="node2">
>