You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Alston, Brian (US SSA)" <br...@baesystems.com> on 2009/03/19 18:40:14 UTC

Need Help With Clustered Tomcat Sessions

Hello All

    I am having trouble with my Tomcat cluster that I hope you can help with. First my setup:

    Apache Load Balancer: Windows Server 2003 - Apache 2.2.11 - 192.168.1.100
    Tomcat Server 1: Windows Server 2003 - Tomcat 6.0.18 - 192.168.1.110
    Tomcat Server 2: Windows Server 2003 - Tomcat 6.0.18 - 192.168.1.120

When I go to the Apache load balancer (http://192.168.1.100) the page comes up fine. When I go to the Java examples (http://192.168.1.100/examples/) and click on "Servlets Examples" and then on "Sessions -> Execute" the page also comes up fine. It is here when I start to have problems.

    First, let me explain how I know I have problems. Here is another setup I have:

    Apache Load Balancer: RedHat Enterprise Linux 5 - Apache 2.2.3 - 192.168.2.100
    Tomcat Server 1: Windows Server 2003 - Tomcat 6.0.18 - 192.168.2.110
    Tomcat Server 2: Windows Server 2003 - Tomcat 6.0.18 - 192.168.2.120

When I go to my Linux load-balanced cluster and enter "Name/Value Session Attributes" into the "Sessions" Servlet Examples, they accumulate and I maintain the exact same "Session ID". For example:

Session ID: CCAE9F2E90A5311166E7B67CE003A727.tomcat1
The following data is in your session:
    color-sky = blue
    color-grass = green
    color-firetruck = red
    color-cloud = white

No matter what I enter, I get an additional "Name/Value Session Attribute" pair and the exact same "Session ID".

Now, back to my Windows Server 2003 load-balanced cluster. Whenever I enter any "Name/Value Session Attribute" pairs, the new name/value pair always replaces the old, and I end up with an entirely new "Session ID" to boot:

Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat2
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat2
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
    .
    .
    .


I am hoping that there is a simple fix for this because I have no clue. My Apache httpd.conf file and Tomcat server.xml files are exactly the same between the Linux load-balanced cluster and the Windows Server 2003 load-balanced cluster, so I assume that cannot be the cause.

Any help will be greatly appreciated. Thanks for reading and have a good day.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Need Help With Clustered Tomcat Sessions

Posted by André Warnier <aw...@ice-sa.com>.
Christopher Schultz wrote:
> 
> Get yourself an HTTP sniffer to verify that this is what is happening:
> 
Maybe easier in this case, a simple browser add-on :
Firefox : LiveHttpHeaders or HttpFox
IE : Fiddler
They allow you to see what the browser sends to the server, and what the
server returns, including redirects, cookies, etc..




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


Re: Need Help With Clustered Tomcat Sessions

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

Brian,

On 3/20/2009 10:21 AM, Alston, Brian (US SSA) wrote:
> When I go to http://192.168.1.100/examples (no trailing slash), I
> actually get forwarded to a Tomcat server and end up at
> http://192.168.1.110:8080/examples . If this happens, the "Session
> ID" stays the same and all my name/value pairs accumulate in the
> "session" example. However, If I keep adding a trailing slash[, then]
> the URL in the address bar stays that of the load-balancer, BUT,
every time I add a new name/value pair to the "session" example I get a
new "Session ID" and my name/value pairs keep getting overwritten.

This is very good information. Nice investigation, especially because it
leads directly to a conclusion:

Your JSESSIONID cookies have the "wrong" information in them.

Get yourself an HTTP sniffer to verify that this is what is happening:

1. You make a connection to http://192.168.1.100/examples/
2. The request is re-routed to http://192.168.1.110:8080/examples/
3. The server responds with a Set-Cookie header including
   host=192.168.1.110
4. Your next request goes to http://192.168.1.100/examples/, so
   the browser never sends the JSESSIONID cookie back to the server

You need to make sure that the URL the client sees matches the hostname
used in the Set-Cookie header.

When you leave-off the trailing /, the server sends a REDIRECT back to
the client and says "go to http://192.168.1.110:8080/examples/", and
then everything works fine (because the hostname changes as far as the
client is concerned).

How do you have Apache talking to Tomcat? Are you using mod_proxy_http?
mod_proxy_ajp? mod_jk?

> So what does everybody think? Is this a simple issue or more complex?
> Is this simply a "URL Rewrite" issue or something else?

It's more likely that you are using mod_proxy_http, and you haven't
properly configured a ProxyPassReverse for your servers.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAknD/e4ACgkQ9CaO5/Lv0PDXMwCgiq0k00vwDRPtGuACUbHuOfEE
lvMAnAyE59SYdniJ77KU0sUILaSgKthn
=jiRr
-----END PGP SIGNATURE-----

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


RE: Need Help With Clustered Tomcat Sessions

Posted by "Alston, Brian (US SSA)" <br...@baesystems.com>.

I feel I must apologise. Upon closer examination, it appears I am having the same problem with my Linux load-balancer as well. It looks like I may a "compound" issue. The initial confusion started with the different way that Linux and Windows Apache servers handle the "trailing slash" for a URL. The Windows Apache would not see the trailing slash and break, so I was able to notice the problem. The Linux Apache server would not see the trailing slash, but would gracefully work around it. The other issue may also be connected to the trailing slash issue but I'm not sure, I'll try to explain it as best I can.

    When I go to http://192.168.1.100/examples (no trailing slash), I actually get forwarded to a Tomcat server and end up at http://192.168.1.110:8080/examples . If this happens, the "Session ID" stays the same and all my name/value pairs accumulate in the "session" example. However, If I keep adding a trailing slash:

    http://192.168.1.100/examples/
    http://192.168.1.100/examples/servlets/
    etc.

Then the URL in the address bar stays that of the load-balancer, BUT, every time I add a new name/value pair to the "session" example I get a new "Session ID" and my name/value pairs keep getting overwritten.

This, of course, wont work because there is now no more load balancing or failover protection.

So ... I am now not sure if this is a "trailing slash" issue or a "sessions" issue, both or neither. If I use a static page placed in:

    C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\examples\test.html

the load-balancing and failover work perfectly. It appears to only break if there is some kind of session/dynamic content on the page.

So what does everybody think? Is this a simple issue or more complex? Is this simply a "URL Rewrite" issue or something else?



Thank you so much for reading and replying.


________________________________________
From: Alston, Brian (US SSA) [brian.alston@baesystems.com]
Sent: Thursday, March 19, 2009 3:32 PM
To: Tomcat Users List
Subject: RE: Need Help With Clustered Tomcat Sessions

    Yes I am.

    The frustrating thing is I have 2 Tomcat servers and 2 Apache load balancers. One load balancer is Linux and one load balancer is Windows Server 2003 (I never have them both on at the same time). I can turn off my Windows load balancer, turn on my Linux load balancer, and the sessions work perfectly. It is some kind of issue with the Windows load balancer but I just cannot figure it out. My Apache load balancing configurations are the same between the Linux and Windows servers; the only difference is that the Linux load balancer works and the Windows one does not work, so you can see why I want to pull my hair out. I would simply stick with the Linux load balancer but they want me to use the Windows one, so I'm stuck.


________________________________________
From: Jorge Medina [jmedina@e-dialog.com]
Sent: Thursday, March 19, 2009 3:13 PM
To: Tomcat Users List
Subject: RE: Need Help With Clustered Tomcat Sessions

Are you maintaining session stickyness?

Did you configure Tomcat to replicate the sessions?


-----Original Message-----
From: Alston, Brian (US SSA) [mailto:brian.alston@baesystems.com]
Sent: Thursday, March 19, 2009 1:40 PM
To: users@tomcat.apache.org
Subject: Need Help With Clustered Tomcat Sessions

Hello All

    I am having trouble with my Tomcat cluster that I hope you can help
with. First my setup:

    Apache Load Balancer: Windows Server 2003 - Apache 2.2.11 -
192.168.1.100
    Tomcat Server 1: Windows Server 2003 - Tomcat 6.0.18 - 192.168.1.110
    Tomcat Server 2: Windows Server 2003 - Tomcat 6.0.18 - 192.168.1.120

When I go to the Apache load balancer (http://192.168.1.100) the page
comes up fine. When I go to the Java examples
(http://192.168.1.100/examples/) and click on "Servlets Examples" and
then on "Sessions -> Execute" the page also comes up fine. It is here
when I start to have problems.

    First, let me explain how I know I have problems. Here is another
setup I have:

    Apache Load Balancer: RedHat Enterprise Linux 5 - Apache 2.2.3 -
192.168.2.100
    Tomcat Server 1: Windows Server 2003 - Tomcat 6.0.18 - 192.168.2.110
    Tomcat Server 2: Windows Server 2003 - Tomcat 6.0.18 - 192.168.2.120

When I go to my Linux load-balanced cluster and enter "Name/Value
Session Attributes" into the "Sessions" Servlet Examples, they
accumulate and I maintain the exact same "Session ID". For example:

Session ID: CCAE9F2E90A5311166E7B67CE003A727.tomcat1
The following data is in your session:
    color-sky = blue
    color-grass = green
    color-firetruck = red
    color-cloud = white

No matter what I enter, I get an additional "Name/Value Session
Attribute" pair and the exact same "Session ID".

Now, back to my Windows Server 2003 load-balanced cluster. Whenever I
enter any "Name/Value Session Attribute" pairs, the new name/value pair
always replaces the old, and I end up with an entirely new "Session ID"
to boot:

Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat2
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat2
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
    .
    .
    .


I am hoping that there is a simple fix for this because I have no clue.
My Apache httpd.conf file and Tomcat server.xml files are exactly the
same between the Linux load-balanced cluster and the Windows Server 2003
load-balanced cluster, so I assume that cannot be the cause.

Any help will be greatly appreciated. Thanks for reading and have a good
day.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


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


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


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


RE: Need Help With Clustered Tomcat Sessions

Posted by "Alston, Brian (US SSA)" <br...@baesystems.com>.

    Yes I am.

    The frustrating thing is I have 2 Tomcat servers and 2 Apache load balancers. One load balancer is Linux and one load balancer is Windows Server 2003 (I never have them both on at the same time). I can turn off my Windows load balancer, turn on my Linux load balancer, and the sessions work perfectly. It is some kind of issue with the Windows load balancer but I just cannot figure it out. My Apache load balancing configurations are the same between the Linux and Windows servers; the only difference is that the Linux load balancer works and the Windows one does not work, so you can see why I want to pull my hair out. I would simply stick with the Linux load balancer but they want me to use the Windows one, so I'm stuck.


________________________________________
From: Jorge Medina [jmedina@e-dialog.com]
Sent: Thursday, March 19, 2009 3:13 PM
To: Tomcat Users List
Subject: RE: Need Help With Clustered Tomcat Sessions

Are you maintaining session stickyness?

Did you configure Tomcat to replicate the sessions?


-----Original Message-----
From: Alston, Brian (US SSA) [mailto:brian.alston@baesystems.com]
Sent: Thursday, March 19, 2009 1:40 PM
To: users@tomcat.apache.org
Subject: Need Help With Clustered Tomcat Sessions

Hello All

    I am having trouble with my Tomcat cluster that I hope you can help
with. First my setup:

    Apache Load Balancer: Windows Server 2003 - Apache 2.2.11 -
192.168.1.100
    Tomcat Server 1: Windows Server 2003 - Tomcat 6.0.18 - 192.168.1.110
    Tomcat Server 2: Windows Server 2003 - Tomcat 6.0.18 - 192.168.1.120

When I go to the Apache load balancer (http://192.168.1.100) the page
comes up fine. When I go to the Java examples
(http://192.168.1.100/examples/) and click on "Servlets Examples" and
then on "Sessions -> Execute" the page also comes up fine. It is here
when I start to have problems.

    First, let me explain how I know I have problems. Here is another
setup I have:

    Apache Load Balancer: RedHat Enterprise Linux 5 - Apache 2.2.3 -
192.168.2.100
    Tomcat Server 1: Windows Server 2003 - Tomcat 6.0.18 - 192.168.2.110
    Tomcat Server 2: Windows Server 2003 - Tomcat 6.0.18 - 192.168.2.120

When I go to my Linux load-balanced cluster and enter "Name/Value
Session Attributes" into the "Sessions" Servlet Examples, they
accumulate and I maintain the exact same "Session ID". For example:

Session ID: CCAE9F2E90A5311166E7B67CE003A727.tomcat1
The following data is in your session:
    color-sky = blue
    color-grass = green
    color-firetruck = red
    color-cloud = white

No matter what I enter, I get an additional "Name/Value Session
Attribute" pair and the exact same "Session ID".

Now, back to my Windows Server 2003 load-balanced cluster. Whenever I
enter any "Name/Value Session Attribute" pairs, the new name/value pair
always replaces the old, and I end up with an entirely new "Session ID"
to boot:

Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat2
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat2
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
    .
    .
    .


I am hoping that there is a simple fix for this because I have no clue.
My Apache httpd.conf file and Tomcat server.xml files are exactly the
same between the Linux load-balanced cluster and the Windows Server 2003
load-balanced cluster, so I assume that cannot be the cause.

Any help will be greatly appreciated. Thanks for reading and have a good
day.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


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


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


RE: Need Help With Clustered Tomcat Sessions

Posted by Jorge Medina <jm...@e-dialog.com>.
Are you maintaining session stickyness? 

Did you configure Tomcat to replicate the sessions?


-----Original Message-----
From: Alston, Brian (US SSA) [mailto:brian.alston@baesystems.com] 
Sent: Thursday, March 19, 2009 1:40 PM
To: users@tomcat.apache.org
Subject: Need Help With Clustered Tomcat Sessions

Hello All

    I am having trouble with my Tomcat cluster that I hope you can help
with. First my setup:

    Apache Load Balancer: Windows Server 2003 - Apache 2.2.11 -
192.168.1.100
    Tomcat Server 1: Windows Server 2003 - Tomcat 6.0.18 - 192.168.1.110
    Tomcat Server 2: Windows Server 2003 - Tomcat 6.0.18 - 192.168.1.120

When I go to the Apache load balancer (http://192.168.1.100) the page
comes up fine. When I go to the Java examples
(http://192.168.1.100/examples/) and click on "Servlets Examples" and
then on "Sessions -> Execute" the page also comes up fine. It is here
when I start to have problems.

    First, let me explain how I know I have problems. Here is another
setup I have:

    Apache Load Balancer: RedHat Enterprise Linux 5 - Apache 2.2.3 -
192.168.2.100
    Tomcat Server 1: Windows Server 2003 - Tomcat 6.0.18 - 192.168.2.110
    Tomcat Server 2: Windows Server 2003 - Tomcat 6.0.18 - 192.168.2.120

When I go to my Linux load-balanced cluster and enter "Name/Value
Session Attributes" into the "Sessions" Servlet Examples, they
accumulate and I maintain the exact same "Session ID". For example:

Session ID: CCAE9F2E90A5311166E7B67CE003A727.tomcat1
The following data is in your session:
    color-sky = blue
    color-grass = green
    color-firetruck = red
    color-cloud = white

No matter what I enter, I get an additional "Name/Value Session
Attribute" pair and the exact same "Session ID".

Now, back to my Windows Server 2003 load-balanced cluster. Whenever I
enter any "Name/Value Session Attribute" pairs, the new name/value pair
always replaces the old, and I end up with an entirely new "Session ID"
to boot:

Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat2
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat2
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
Session ID: xxxxXXXXxxxxXXXXxxxxXXXXxxxxXXXX.tomcat1
    .
    .
    .


I am hoping that there is a simple fix for this because I have no clue.
My Apache httpd.conf file and Tomcat server.xml files are exactly the
same between the Linux load-balanced cluster and the Windows Server 2003
load-balanced cluster, so I assume that cannot be the cause.

Any help will be greatly appreciated. Thanks for reading and have a good
day.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


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