You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "universeprojects.com" <ni...@gmail.com> on 2009/06/04 19:33:44 UTC

AJAX Calls not resetting tomcat's session timeout

I'm developing a web-app using netbeans with glassfish v2 and my actual
server is apache tomcat version 6. My application makes an AJAX call to the
server to check for updates once every second. 

When I'm testing on glassfish, the session stays alive past the 1 minute
timeout (because of the AJAX calls to the server) however when I deploy onto
my apache tomcat server, the AJAX calls are NOT resetting the session
timeout and the session times out after 1 minute. 

It is my understanding that glassfish is based off of the apache server so
the settings files should be identical.

My question is: Is there a server configuration setting somewhere that will
make tomcat behave the way glassfish does? (In that it will reset the
session timeout when it recieves an AJAX request)
-- 
View this message in context: http://www.nabble.com/AJAX-Calls-not-resetting-tomcat%27s-session-timeout-tp23874506p23874506.html
Sent from the Tomcat - User mailing list archive at Nabble.com.

Re: AJAX Calls not resetting tomcat's session timeout

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

To whom it may concern,

On 6/4/2009 4:13 PM, universeprojects.com wrote:
> Caldarale, Charles R wrote:
>> 3) What <Connector> flavor are you using?
>
> 3. Catalina? (Does that make sense? I'm a little newbish) Whatever defaults
> with tomcat

The default would be a non-APR HTTP connector on port 8080. You could
just look in conf/server.xml for all <Connector> elements that haven't
been commented-out and post them, here.

Regarding "APR"... have you installed any kind of native library into
your Tomcat instance? If not, then you are probably not using APR.

> One thing, I think I may have been using 6.0.7. I've since re-installed to
> 6.0.14 and will be watching to see if it has any effect. (I was getting
> conflicting version numbers so perhaps it was just the windows service
> description that had the old version number on it. We'll see...)

Both of these versions should be performing equally well.

Something interesting to do would be to install a filter that watches
your AJAX requests and reports which session is being referenced.
Something like this would work:

public class SessionIdReporterFilter
    implements javax.servlet.Filter
{
    private ServletContext _app;

    public void init(FilterConfig config)
    {
        _app = config.getServletContext();
    }

    public void doFilter(ServletRequest req,
                         ServletResponse rsp,
                         FilterChain chain)
        throws IOException, ServletException
    {
        if(req instanceof HttpServletRequest)
        {
           HttpServletRequest request = (HttpServletRequest)req;

            _app.log("Got a request for " + request.getRequestURL()
                     "; using sessionid="
                     + request.getRequestedSessionId()
                     "; session=" + request.getSession(false));
        }

        chain.doFilter(req, rsp);
    }
}

Enable this in your webapp's web.xml like this:

<filter>
   <filter-name>sessionIdReporter</filter-name>
   <filter-class>fully.qualified.SessionIdReporterFilter<filter-class>
   <description>
      Reports the requested session id and resulting session used
      to handle a request. Logs to the application's context log.
   </description>
</filter>

<filter-mapping>
   <filter-name>sessionIdReporter</filter-name>
   <url-pattern>/whatever/matches/your/ajax/requests</url-pattern>
</filter-mapping>

The <filter> and <filter-mapping> elements go in web.xml before any
<servlet> or <listener> declarations.

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

iEYEARECAAYFAkooOEMACgkQ9CaO5/Lv0PDihwCfdEsm9cOAM64PFtz7VWy7m0ry
xfIAoL1mKtEd3GCVlgUbq2lU0bzOuROP
=WX0T
-----END PGP SIGNATURE-----

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


RE: AJAX Calls not resetting tomcat's session timeout

Posted by "universeprojects.com" <ni...@gmail.com>.
1. Using cookies

2. Ok I'll look into it

3. Catalina? (Does that make sense? I'm a little newbish) Whatever defaults
with tomcat

4. Nothing like that no. 

One thing, I think I may have been using 6.0.7. I've since re-installed to
6.0.14 and will be watching to see if it has any effect. (I was getting
conflicting version numbers so perhaps it was just the windows service
description that had the old version number on it. We'll see...)



Caldarale, Charles R wrote:
> 
>> From: universeprojects.com [mailto:nikolasarmstrong@gmail.com]
>> Subject: RE: AJAX Calls not resetting tomcat's session timeout
>> 
>> Version 6.0.14
> 
> There were a few session-related fixes made since 6.0.14, but a brief scan
> of the changelog doesn't reveal anything that matches your symptoms.  I
> haven't tried to search bugzilla.
> 
> More questions:
> 
> 1) Are you using cookies or is the session id included in the URL?
> 
> 2) Can you get a Wireshark trace of the situation to make sure the session
> id is being sent with each AJAX call?  (Preferably two traces, one from
> each end of the connection.)
> 
> 3) What <Connector> flavor are you using?
> 
> 4) Is there anything in between the client and Tomcat (e.g., load
> balancer, httpd, proxy) that might be fiddling with the URL or content?
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/AJAX-Calls-not-resetting-tomcat%27s-session-timeout-tp23874506p23876920.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


RE: AJAX Calls not resetting tomcat's session timeout

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: universeprojects.com [mailto:nikolasarmstrong@gmail.com]
> Subject: RE: AJAX Calls not resetting tomcat's session timeout
> 
> Version 6.0.14

There were a few session-related fixes made since 6.0.14, but a brief scan of the changelog doesn't reveal anything that matches your symptoms.  I haven't tried to search bugzilla.

More questions:

1) Are you using cookies or is the session id included in the URL?

2) Can you get a Wireshark trace of the situation to make sure the session id is being sent with each AJAX call?  (Preferably two traces, one from each end of the connection.)

3) What <Connector> flavor are you using?

4) Is there anything in between the client and Tomcat (e.g., load balancer, httpd, proxy) that might be fiddling with the URL or content?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


RE: AJAX Calls not resetting tomcat's session timeout

Posted by "universeprojects.com" <ni...@gmail.com>.
Version 6.0.14

Thanks for the help! 



Caldarale, Charles R wrote:
> 
>> From: universeprojects.com [mailto:nikolasarmstrong@gmail.com]
>> Subject: AJAX Calls not resetting tomcat's session timeout
>> 
>> my actual server is apache tomcat version 6.
> 
> Which exact level of Tomcat version 6?
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/AJAX-Calls-not-resetting-tomcat%27s-session-timeout-tp23874506p23874985.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


RE: AJAX Calls not resetting tomcat's session timeout

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: universeprojects.com [mailto:nikolasarmstrong@gmail.com]
> Subject: AJAX Calls not resetting tomcat's session timeout
> 
> my actual server is apache tomcat version 6.

Which exact level of Tomcat version 6?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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