Re: Internals of setMaxInactiveInterval

2021-07-14 Thread Christopher Schultz

Saurav,

On 7/12/21 23:33, Saurav Sarkar wrote:

Hi All,

I would like to understand the internals of Session~setMaxInactiveInterval
in tomcat.

I understand that if HTTP requests are not received within the said
interval then the session is cleared. All the objects belonging to the
session will be gone.

Does that also mean that the existing requests part of the session will be
terminated ?

I have a scenario for large file transfer to happen over a single request.

So if one request (A) is long running and there are no other requests sent
within the time interval.

Then will the request A will be terminated and subsequent requests even if
with valid cookie will not be part of the same session ? Or will the
ongoing request's fate is determined by other timeouts like read time out?


Requests that were related to a certain session will never be terminated 
due to a session state-change.


But, if your servlet works like this, you may have a problem:

doGet() {
  HttpSession session = request.getSession(true);

  // take 45 minutes to stream data to the client

  session.setAttribute("foo", "bar");
}

My recommendation would be to do all of your session-work "up front" 
(before the long data-stream) and not touch the session after the 
download completes.


This may not meet your requirements, but if you are doing extraordinary 
things, you may require extraordinary workarounds :)


-chris

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



Re: Internals of setMaxInactiveInterval

2021-07-13 Thread Mark Thomas

On 13/07/2021 04:33, Saurav Sarkar wrote:

Hi All,

I would like to understand the internals of Session~setMaxInactiveInterval
in tomcat.

I understand that if HTTP requests are not received within the said
interval then the session is cleared. All the objects belonging to the
session will be gone.

Does that also mean that the existing requests part of the session will be
terminated ?

I have a scenario for large file transfer to happen over a single request.

So if one request (A) is long running and there are no other requests sent
within the time interval.

Then will the request A will be terminated and subsequent requests even if
with valid cookie will not be part of the same session ? Or will the
ongoing request's fate is determined by other timeouts like read time out?


Session expiry depends on various settings.

See http://tomcat.apache.org/tomcat-10.0-doc/config/manager.html

sessionActivityCheck
sessionLastAccessAtStart

You can choose the values for those settings that best meet your 
requirements.


I'd suggest
sessionActivityCheck="true"
sessionLastAccessAtStart="false"

Mark

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