Re: AW: Sticky sessions with Apache and Tomcat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well, it's not a static page. I'll explain the situation better. I have a
message at the top of my page to show me which machine I've been handed to.
Machine 1 says "You are viewing this page from machine 1" and Machine 2 says
"You are are viewing this page from machine 2". So, when I get the page I
know which server it came from. I can also include a URL variable which will
set a session variable. setSession=true in the URL.

1.) I visit the site with setSession=true, it sets the session variable
called "visited" to true. On this page I see "You are viewing this page from
machine 1". I also see that the session variable exists and is true.

2.) I visit the site again and now (without setSession) I see "You are
visiting this page from machine 2" and it says that the session variable
doesn't exist.

3.) I visit again (also without setSession), I see "You are visiting this
page from machine 1" and it says the session variable does exist. So, my
session variable from the first visit still exists, it knows who I am. 

4.) Back to machine 2 again

It just goes back and forth like this. Machine 2 never realizes my session,
but Machine 1 does, so my session has been set. 

For whatever reason it keeps throwing me between machines.

So, I keep getting thrown back and forth between servers.



Juergen.Link-2 wrote:
> 
> Did you check the session cookie in your browser? 
> There should be one and it must end with either .jvm1 or .jvm2.
> If there is no session cookie, maybe your application didn't yet start a
> session - e.g. static html pages are served w/o a session.
> 
> Cheers
> Jürgen
> 
> 
>> -----Ursprüngliche Nachricht-----
>> Von: tomcatastrophe [mailto:nabble@xxxxxxxxxxxxxxxx] 
>> Gesendet: Montag, 13. Juli 2009 19:23
>> An: users@xxxxxxxxxxxxxxxx
>> Betreff:  Sticky sessions with Apache and Tomcat
>> 
>> 
>> I am trying to set up simple load balancing between Apache 
>> and two Tomcat instances, but am having problems with sticky sessions.
>> 
>> I get thrown back and forth between the instances on each 
>> request. (I put a note at the top of the page on each 
>> instance to distinguish where the page has been served from 
>> and each request sends me back to the other server. I see 
>> "instance 1" at the top of the page, then refresh and see 
>> instance 2, then refresh and see instance 1 again, etc)
>> 
>> My Apache Virtual Host:
>> 
>> <VirtualHost *:80>
>>      DocumentRoot "C:/Program Files (x86)/Apache Software 
>> Foundation/Tomcat 6.0/sites/foo/ROOT/"
>>      ServerName foo.com
>>      ServerAlias www.foo.com
>>      DirectoryIndex index.php
>> 
>>      <Directory "C:/Program Files (x86)/Apache Software 
>> Foundation/Tomcat 6.0/sites/foo/ROOT/">
>>      Allow from all
>>      </Directory>
>> 
>> 
>>      ProxyPreserveHost On
>>      ProxyPassReverse / ajp://192.168.1.2:8009/
>>      ProxyPassReverse / ajp://192.168.1.3:8009/
>> 	 
>>      ProxyPass / balancer://mycluster 
>> stickysession=JSESSIONID|jsessionid
>> nofailover=Off
>> 	 
>>      ProxyPass /balancer-manager !
>> 	 
>>      RewriteEngine On
>>      RewriteRule ^/(.*)$ balancer://mycluster/$1 [P,L,R]
>> 	 
>> <Proxy balancer://mycluster>
>> 	BalancerMember ajp://192.168.1.2:8009/ route=jvm1 loadfactor=50
>> 	BalancerMember ajp://192.168.1.3:8009/ route=jvm2 loadfactor=50
>> 	ProxySet lbmethod=byrequests
>> </Proxy>
>> 
>> <Location /balancer-manager>
>>         SetHandler balancer-manager
>>         Order Deny,Allow
>>         Deny from all
>>         Allow from 127.0.0.1
>> </Location>
>> 
>> </VirtualHost> 
>> 
>> 
>> My two Tomcat instances are set up as:
>> 
>>     <Engine name="Standalone" defaultHost="localhost" 
>> jvmRoute="jvm1">   
>> 
>>  and
>> 
>>     <Engine name="Standalone" defaultHost="localhost" 
>> jvmRoute="jvm2">   
>> 
>> 
>> Basically, what I want to happen is when I type in 
>> http://foo.com in the browser I am taken to jvm1 instance, 
>> when I type the same thing in another browser (new session) I 
>> am taken to jvm2 instance.
>> 
>> Then, everytime I visit any page on foo.com from either 
>> browser, I am always served from the original instance I was assigned.
>> 
>> Any help?
>> 
>> Thanks!!!
>> --
>> View this message in context: 
>> http://www.nabble.com/Sticky-sessions-with-Apache-and-Tomcat-t
>> p24465853p24465853.html
>> Sent from the Apache HTTP Server - Users mailing list archive 
>> at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> The official User-To-User support forum of the Apache HTTP 
>> Server Project.
>> See <URL:http://httpd.apache.org/userslist.html> for more info.
>> To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
>>    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
>> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>> 
>> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
>    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Sticky-sessions-with-Apache-and-Tomcat-tp24465853p24489722.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux