5 Replies Latest reply on Aug 6, 2008 9:49 AM by Vackar

    Session Timeout Not Detected From Flex App

    Vackar Level 2
      Hi,

      I have a flex application which is deployed from a tomcat server. The application hosting the flex app has been configured to timeout in X minutes in web.xml

      quote:


      <session-config>
      <session-timeout>X</session-timeout>
      </session-config>



      when x minutes have expired the users session is lost, but the flex application continues to run irrespective. Since the session is lost, the remote objects start doing some weird things when they are called - but from the user's perspective everythign seems OK. Only when a user requests a resource on the page wrapping the swf file do they get redrected to the login screen.


      Any help would be much appreciated
      I am using a SecureAMFChannel which looks like this:
        • 1. Re: Session Timeout Not Detected From Flex App
          Vackar Level 2
          Ok, I managed to stop the session from expiring by sending ajax requests to the server every 30 seconds, but I don't believe this should be necassary. I'm sure that Flex should have a build in solution for this kind of thing.

          Any help on this issue wold be very much appreciated.
          Vackar
          • 2. Re: Session Timeout Not Detected From Flex App
            ntsiii Level 3
            Flex is a stateful, client side, presentation technology. There is no required communication with a server at all. Sessions are to support stateless HTML pages. So there is no built-in Flex-Server session functionality.

            "pinging" the server is a common task.

            What do you want to happen when a server-side session times out?
            Tracy
            • 3. Re: Session Timeout Not Detected From Flex App
              Vackar Level 2
              Hi Tracy,

              Thanks for the info about how Flex works, and the suggestion about pinging the server. My problem is that on the server I have remote object with application scope, which uses a JPA (Toplink) entity manager. This works fine as long as the session is active, but when the session expires the entity manger returns inaccurate results, and doesn't save properly. Do you think this is related to the session expiry, or am I simply overlooking something more trivial.

              Thanks,
              Vackar
              • 4. Re: Session Timeout Not Detected From Flex App
                ntsiii Level 3
                I do not know those server technologies so I can't suggest anything specific, but I would think that this issue should be handled server-side.
                Tracy
                • 5. Re: Session Timeout Not Detected From Flex App
                  Vackar Level 2
                  Hi,

                  Yeah it turned out to be a server-side issue, not a flex one. I had bound my EntityManager instance to ThreadLocal meaning that it was effectively invisible to other threads. I think what happened was that when the session times out, the associated thread resources are released and garbage collected, and that's why things started going weird. But thanks for your help, and maybe this can help someone who has similar problems in the future.