Bug 37269 - sticky session doesn't seem to work
Summary: sticky session doesn't seem to work
Status: RESOLVED INVALID
Alias: None
Product: Tomcat Connectors
Classification: Unclassified
Component: Common (show other bugs)
Version: unspecified
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-27 15:54 UTC by R
Modified: 2008-10-05 03:09 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description R 2005-10-27 15:54:51 UTC
Hi,

I don't know if this is the right place, maybe it's a bug in mod_jk, maybe in
Tomcat, or maybe there's no bug at all...

I have configured a mod_jk loadbalancer on Apache 2. I have two tomcats running
on  two differents servers. I don't have activated the cluster element in
server.xml. Both tomcats are running the same webapp. In the title of every jsp
I write the name of the server so that I can check that sticky session works.
And it doesn't.

Here is my workers.properties :

----------------------------------------------------------
worker.list=loadbalancer,status
worker.node1.port=8009
worker.node1.host=noeud_1
worker.node1.type=ajp13
worker.node1.lbfactor=1

worker.node2.port=8009
worker.node2.host=noeud_2
worker.node2.type=ajp13
worker.node2.lbfactor=1

worker.loadbalancer.type=lb
worker.loadbalancer.sticky_session=true
worker.loadbalancer.balance_workers=node1, node2

# Status worker for managing load balancer
worker.status.type=status

----------------------------------------------------------

noeud_1 and noeud_2 are the tomcat servers.

In each tomcats I've added the jvmRoute attribute :

----------------------------------------------------------
<Engine name="Catalina" defaultHost="localhost"	jvmRoute="noeud_1">
------------------------------------------------------------

Of course on the noeud_2 server I wrote jvmRoute="noeud_2"...

Here is my jk.load file :

-----------------------------------------------------------
JkWorkersFile /etc/apache2/workers.properties

JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel info
JkLogStampFormat  "[%a %b %d %H:%M:%S %Y]"

# JkOptions indicates to send SSK KEY SIZE
#JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

JkRequestLogFormat "%w %V %T"

JkMount /* loadbalancer
JkMount /jkstatus status

JkShmFile /var/log/apache2/jk.shm

<Location /jkstatus/>
        JkMount status
        Order deny,allow
        Deny from all
        Allow from all
</Location>
------------------------------------------------------------

And finally here is the way I write the server name in jsps :

<title><% java.net.InetAddress local =
java.net.InetAddress.getLocalHost();out.print(local.getHostName()); %></title>



Now the test :

I open http://MY_SERVER/ in firefox :

I see "noeud_1" in the title.
I have a JSESSIONIN in HTTP Headers.
I press F5 to reload
I see "noeud_2" in the title.
I still have the same JSESSIONID...

So is it normal ? I think that the point of sticky session is to always redirect
to the same server right ? Did I forgot something in some config files ?
Comment 1 R 2005-10-28 12:21:11 UTC
I got it to work : the jvmRoute attribute must be the name of the worker, not
the name of the server... This is not documented, the doc only says the the
jvmRoute mus be unique.
Comment 2 R 2005-11-02 11:12:00 UTC
"The second word is the worker name that can be any name. The worker name
reflects the name of the jvmRoute defined in Tomcat's server.xml configuration
file."

Sorry...