5

In my nginx I have set upstream and setup sticky session with:

upstream tomcat {
      ip_hash;
      server localhost:XXXX;
      server localhost:XXXY;
      server localhost:XXYY;
}

I have added <distributable/> tag in my web.xml (in all tomcats)

Have added this in my tomcat/conf/server.xml file:

<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
                 channelSendOptions="6">
          <Channel className="org.apache.catalina.tribes.group.GroupChannel">
            <Membership className="org.apache.catalina.tribes.membership.McastService"
                        address="228.0.0.4"
                        port="45564"
                        frequency="500"
                        dropTime="3000"/>
            <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                      address="auto"
                      port="5000"
                      selectorTimeout="100"
                      maxThreads="6"/>

            <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
              <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
            </Sender>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
          </Channel>

          <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
                 filter=".*\.gif|.*\.js|.*\.jpeg|.*\.jpg|.*\.png|.*\.htm|.*\.html|.*\.css|.*\.txt"/>

          <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
                    tempDir="/tmp/war-temp/"
                    deployDir="/tmp/war-deploy/"
                    watchDir="/tmp/war-listen/"
                    watchEnabled="false"/>

          <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
        </Cluster>

Have added this in my tomcat/conf/context.xml:

<Manager className="org.apache.catalina.ha.session.BackupManager"
                   expireSessionsOnShutdown="false"
                   notifyListenersOnReplication="true"
                   mapSendOptions="6"/>

But now I am able to login to my application. What happens is if all 3 or any 2 instances are started and I login, I see the JSESSIONID e..g xyz234.tomcat1

Now if I turn off tomcat1, it will take me back to login page since tomcat1 is shutdown. I login again and it creates session with say tomcat2, meanwhile, I turn tomcat1 up again, my application will take me back to login page. So, I face two problems:

  1. I want to stay login even either of my tomcat (holding session) goes down.
  2. And if that tomcat comes up again, I should still stay up.

Note: I am using JSF2 app, so not sure if it has anything to do with it.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
SSC
  • 2,956
  • 3
  • 27
  • 43
  • A ***PrimeFaces*** ``? – Kukeltje Dec 08 '15 at 23:04
  • @Kukeltje JSF Html tag :-) – SSC Dec 09 '15 at 01:51
  • @Kukeltje Any idea what might be wrong or what should I really look into? – SSC Dec 09 '15 at 12:19
  • No, sorry, I don't use replication, nginx or whatever. Only thing to do is to debug _"function does not even execute."_ and find the cause... – Kukeltje Dec 09 '15 at 12:27
  • Great bounty, but I still think you can (and should) do more debugging yourself. See my comment above. – Kukeltje Dec 11 '15 at 10:18
  • @Kukeltje I debugged it too much but unable to still find the cause. – SSC Dec 11 '15 at 11:24
  • I never said you should find the cause yourself... See [ask], the first paragraph... the thing about mentioning what you did... It is information (= data with 'value') for others. So they can more easily help out – Kukeltje Dec 11 '15 at 11:30
  • To exclude one and other, do you have `` set in webapp's `web.xml`? This is required when a WAR is to be deployed to a cluster. – BalusC Dec 11 '15 at 18:44
  • I have edited the question accordingly so it is easy to understand (I hope) @BalusC – SSC Dec 11 '15 at 20:12
  • OK, so each Tomcat instance has its own session. This is actually not a programming problem, but a serveradmin problem and question is technically better at its place in http://serverfault.com. Unfortunately, bounty prevents migration. – BalusC Dec 12 '15 at 08:31
  • So, what do you suggest? Should I create a new question in serverfault.com and give a duplicate reference in there? – SSC Dec 12 '15 at 18:37

0 Answers0