Our asp.net 2.0 application has a very long process (synchronized) before sending response back to client. I observed that a second request, exactly same the initial one, was sent after client IE8 waited response for a long period of time while our application was still processing the first request.
I use page session with predefined key to store a flag when the initial request arrives and then starts long process while client IE waits for the response, so if second request comes in, our application checks the session value. After our application sets the session flag and starts processing, I use Fiddler “Abort Session” to abort the initial request, right away the second request (same as the first one) is sent automatically, but session value set earlier seems no longer exist.
Any thoughts?
When the second request comes in during your ongoing process isn't it overwritting your current request's value since it is only storing one item? Assuming both requests are coming in under the same session.
Maybe consider storing a list of items so that you can add the second item to your list of flags and then find any previous items and delete them.
Maybe kill the request currently in the session before starting the second requests session?
I don't really understand your problem / solution all that well but hopefully that helps.
Edit based on your comment:
If it no longer exists it's probably due to your session timing out and wiping the values so the second one wouldn't be able to access it. Is the second connection coming in under the exact same session? Compare the Session IDs in both cases. Also check your timeout.
You could also store this information in your application Cache that has a real long expiry. Have a dictionary with the key being the session ID or even the user if you only want one process per user and then store your value. This when the second request comes in by the same user, you will be able to find it regardless of session ID. Just make sure you are clearing once your process is complete.
Related
I would like to understand the internals of Session~setMaxInactiveInterval
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 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 ?
Best Regards,
Saurav
Why doesn't container create the instance of HTTPSession when it receives first request, the way it does it for ServletContext or ServletConfig?
Since sessions are managed by container, it would be logical to create session instance when it receives the first request, isn't it?
Why don't we have simple getSession() method only i.e. why would someone need to invoke getSessin(false) in this fashion.
Creating a session has an impact on the response: it sets a cookie, and causes every properly encoded URL to have an additional jsessionid inside. You might not want that (for SEO reasons, etc.).
It also has an impact on the server: a session object is created and kept in memory for every user visiting the application. You might not want that. Suppose for example that a bot sends a request every second to your application, and rejects the cookie set by the application server. Your webapp, after 30 minutes, would have 108000 useless sessions in memory.
So starting a session is a deliberate choice by the programmer. If you need one, you create it. If you don't need it, you don't create it.
I've a servlet app deployed in side oc4j.
I am trying to invalidate the user session after 1 minute using:
session.setMaxInactiveInterval(1 * 60);
But What happens is that It takes over 1 minute (and may reach 1 min and half) before the session get destroyed.
Is this an implementation issue, or what?
You seem to be checking the destroy by waiting until HttpSessionListener#sessionDestoryed() get called instead of actually sending a HTTP request to the server after exactly 1 minute.
The session destroy is on most servers managed by a background job which runs at intervals, which can be each minute or more depending on server make/version, configuration and possibly also load. This job checks all open sessions whether it has been expired or not and sweeps the expired ones accordingly. Thus, it is not true that the session destroy is immediately called on the same second as the session is expired as long as the client hasn't sent a request. This background job does not run every second, it would have been too CPU intensive.
The session destroy will however be immediately called whenever the server retrieves a request with a session ID while the session is still present in server's memory but is been expired.
So, you'd either have to accept it or to change your testing methodology.
I'm using a session to hold a class. In the class are things like first name, last name, Message.
I have information in the first name and last name and on each page i go to i can retrieve that information. Now after the session is created, if i give the message property a value and destroy the session and recreate it, all three properties show up as being populated.
However, when i do a response.redirect the message property is lost but the other two are still there.
I've tried doing response.redirect("PageName.apsx",false) but that has not helped my cause.
Why would the message property be dropped?
This is a bit hard to follow. You:
create a session and assign the message property.
you destroy the session (why?) btw I never trust a session kill before a redirect is complete because the client still retains a session id cookie until the request is complete.
magically all three properties are still in the session (you didnt mention when you assign first/last to the session
you redirect and the first two (which you never state where they are set) are lost.
It sounds as though you are creating a new session and setting the message. However the client is sending over the old session id which the server still considers valid. Without seeing how you are killing the session and which session ids are being set/sent in the response/request headers its hard to see (plus no code provided)
We have a performance measurement module that relies on HttpModule and HttpHandlers and works like this:
Request comes in to server for a page.
HttpModule_Begin writes start time in the cookie.
HttpModule_End writes end time in the cookie.
On client, when page load is finished, fire off a special request via AJAX
that is handled by HttpHandler_ProcessRequest
In HttpHandler_ProcessRequest subtract DateTime.Now from end time written by the previous HttpModule_End (which is stored in the cookie) and store it in the database.
One thing I forgot to mention: all data is shared via a cookie, so the HttpHandler, just pulls the data from the cookie without any session id's, etc...
All participants are in the same time zone.
This process works fine for most cases, but there are some instances that report network time in excess of an hour!
This indicates a very large passage of time between the the writing of end time and firing off the AJAX request or a large passage of time between firing off AJAX request and the time it gets to the app server.
I am trying to figure what could be causing this issues in the wild. Why does the operation not simply time out?
Extend your troubleshooting: append values to the IIS log (HttpContext.Current.Response.AppendToLog(string)).
The IIS log will show your entries and you can determine when those requests were actually recorded. You can append whatever you want and it shows up in the query field of the log (assuming you're using W3C format.)
If you're experiencing delays in requests, as the evidence suggests, you can verify it.
This will give you the IIS log as a comparative source against the recorded values in cookies.
Are you including some unique id that allows the AJAX request handler to figure out the which end time to use for the calculation? If not, perhaps enough of the page has been rendered on the client that the AJAX request is actually coming before the end time has been written to the database and it is using the wrong end time.