3 Replies Latest reply on Aug 22, 2011 10:52 AM by kraikit

    Flex Mobile, URLLoader and Sessions

    ixeldog1

      I have created a Flex Mobile Project that I've been testing so far on a Motorola Xoom and uses the URLLoader object to query some JSP pages and return the output. These JSP pages require user authentication which depend on sessions.

       

      If my URLLoader requests are made sequentially (the second request is not made until the first is completed) session information functions normally. If multiple URLLoader requests are made at the same time there is a chance that one or more of the request's session information will fail. I've used a packet sniffer and found that the "Cookie: JSESSION=..." header value is not being set or sent to the server.

       

      I've actually been able to solve this problem by fetching my session ID when I login, storing it locally and setting the "Cookie: JSESSION=..." value manually in the header of all my URLLoader requests. Most of the time the browser will overwrite this value that I've set with the session ID that it has, and that's fine. But in the case where it doesn't set this value then my manually set value is passed to the server and it is able to find the appropriate session.

       

      The solution I've come up with seems to work so far, but I was still wondering if anybody knows what's causing this or knows a better solution?

        • 1. Re: Flex Mobile, URLLoader and Sessions
          kraikit

          That sounds like everything's working the way it should. Until the "first" request is authenticated successfully and the response comes back to the browser/device, your app doesn't have session credentials. Sending multiple simultaneous unauthenticated requests will thus all need to authenticate individually -- and making matters worse, may create multiple sessions on the server, so as they come back your session info (as represented by your JSESSION ids) will rapidly run through all the new sessions until settling on the last one.

           

          I would suggest changing your application flow to let your first request go by itself first and not submit any other requests until that (authenticated) response is received.

           

          -- Tom

          Flex SDK engineer

          • 2. Re: Flex Mobile, URLLoader and Sessions
            ixeldog1 Level 1

            Appreciate the response, and I think that answers my question that this is not some sort of known issue or bug, but I do need to clarify my problem. The first request to the server is an automated login and the session is set correctly. Only after this are the mutliple requests made at the same time. I think it's about 7 requests that all fire at the same time about every 10 seconds (polling system). Sometimes this will function correctly for multiple rounds of requests and everything works fine for 30 seconds or so. Sometimes the first round of requests after the login will fail (session does not persist). Sometimes the first round will succeed and only half of the second round will succeed before failure. I lose the session pretty randomly but I don't think the application has ever made it past 3 or maybe 4 rounds of requests.

            • 3. Re: Flex Mobile, URLLoader and Sessions
              kraikit Level 2

              Based on your description it's not clear if the problem is the server or the client losing sessions. I'd suggest doing some session tracking, either through tracing out the session IDs or trapping them with a web proxy in the middle, and see where in this barrage of requests is the session information being lost, and who (client or server) is the first one to stop using it.

               

              -- Tom Kraikit

              Flex SDK engineer