Thursday, March 28, 2013

Re: GWT Sticky Sessions

Hi there

from my experience ... you are barking at the wrong tree so to speak.
it's a long time that I'm not using GWT anymore (not my choice, but i had to) but i don't think that it's GWT's problem

to check the jsessionid you could use the Chrome's developer tools o firefox - firebug and look at the network tab there you should see the headers sent to the back-end (the jsessionid should be present in a cookie or in the request).
anyway you said mod_jk that says to me that you have an Apache HTTPD before the Tomcat
I usually use mod_proxy_ajp (which i would recommend, but about that we could talk some other time) 
a very important thing when implementing load balancing it's the jvmRoute parameter on the tomcat.
In every tomcat you shold edit in the server.xml the line saying
<Engine name="Catalina" defaultHost="localhost">
adding the an attribute jvmRoute, with a string at your discretion but different for every server.
<Engine name="Catalina" defaultHost="localhost" jvmRoute="t1">
<Engine name="Catalina" defaultHost="localhost" jvmRoute="t2">
...
that makes the Tomcat add that little string at the end of the jsessionid (jsessionid=AS348AF929FK219CKA9FK3B79870H would become jsessionid=AS348AF929FK219CKA9FK3B79870H.t1 on the first server t1 and so on).

that little string there says to the Apache on which node the session  was created and therefore where it should send the request.
from what I've understand from reading this http://blogs.encodo.ch/news/view_article.php?id=18 looks like the jvmRoute value should be the same as the worker name or/and vice-versa.
 
that's about it, hope it helped

See ya



On Wednesday, March 27, 2013 3:32:25 PM UTC+1, xsee wrote:
You don't even need a filter or set the cookie yourself. Just make a call to getSession(true) and it will automagically be set in the Cookies. Typically, you will have some sort of 'initialization' RPC in your module entry point. This is usually a good place to create the session by calling "getLocalThreadRequest().getSession(true). Once your RPC returns, go check your cookies in the browser and you will see the jsessionid there. No need for special filters or any of the rest of it.

On Wednesday, January 23, 2008 4:57:41 AM UTC-7, jas_tat wrote:
Hi All,

I fixed my problem. "Does anyone know how I can pass a plain,
unencoded, jsessionid with all http POST requests which the GWT client
frontend makes?"

In the end I used a servlet filter in order to set a jsessionid as a
cookie for every http response my GWT application made:

import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;

import org.apache.log4j.Logger;

public class JsessionidSetter implements Filter
{
        public static Logger log = Logger.getLogger(JsessionidSetter .class);

        public void init(FilterConfig arg0) throws ServletException
        {
        }

        public void destroy()
        {
        }

        public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException
        {
                HttpServletResponse response = (HttpServletResponse) res;
                HttpSession session = ((HttpServletRequest)req).getSession(true);
                response.addCookie(new Cookie("JSESSIONID", session.getId()));
                chain.doFilter(req, res);
        }
}

With supporting xml in my web.xml:

        <filter>
                <filter-name>JsessionidSetter</filter-name>
                <filter-class>JsessionidSetter</filter-class>
        </filter>
        <filter-mapping>
                <filter-name>JsessionidSetter</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

Thank you all for your comments anyway!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment