This content has been marked as final. Show 12 replies
Are you sure that the RTMPFlexSession for the old FlexClient has been invalidated? The easiest way to figure out which sessions are created/destroyed during your test is to turn LCDS debug logging on with "Endpoint.FlexSession" filter. I'm curious to see the debug log with your test case.
Secondly, there's a FlexClient timeout configuration value that is set in services-config.xml as follows:
Each Flex application that connects to the server triggers the creation of a
FlexClient instance that represents the remote client application.
If timeout-minutes is left undefined or set to 0, FlexClient instances on the server
are shutdown once all associated FlexSessions (corresponding to connections between
the client and server) are shutdown.
If this value is defined, FlexClient instances will be kept alive for this amount of
FlexClient instances that have an associated RTMP connection/session that is open are
kept alive even if they are idle because the open connection indicates that the remote
client application is still running.
For Http connections/sessions, if the remote client application is polling this keeps
the FlexClient alive.
If the remote client is not polling and a FlexClient instance is idle for this amount of time
it is shut down even if an associated HttpSession is still valid. This is because multiple
Flex client applications may share a single HttpSession so a valid HttpSession does not indicate
that a specific client application instance is still running.
I'm not sure if this is related to your test case but something to keep in mind.
>>This is because multiple Flex client applications may share a single HttpSession so a valid HttpSession does not indicate
That is an interesting part. Is there a way to avoid sharing sessions between multiple client apps? May be some config settings?
Yes, the RTMP session gets invalidated. Here is my Logout method:
public void doLogout()
// get the FlexClient associated to this request
FlexClient thisFlexClient = FlexContext.getFlexClient();
// get all the sessions associated to this client
List sessions = thisFlexClient.getFlexSessions();
// contains all the FlexClient associated to this session
List sharedClients = null;
// invalidate all the Flex Sessions for this client
for (Iterator iter = sessions.iterator() ; iter.hasNext();)
// get the next Flex Session
FlexSession fs = (FlexSession)iter.next();
// check if it is the Http Flex Session
if (fs instanceof flex.messaging.HttpFlexSession)
// get the shared Flex clients for this Http Flex session
sharedClients = fs.getFlexClients();
// invalidate this Flex Session
// now search for other non-Http Flex sessions (e.g. RMPT ones) associated
// to Flex clients that shared the same Http Flex session (e.g. multiple browser instances)
// and invalidate them all, to force the correspondent Flex clients to get invalidated
if (sharedClients.size() > 1)
for (Iterator iter2 = sharedClients.iterator() ; iter2.hasNext();)
FlexClient sharedClient = (FlexClient)iter2.next();
if (sharedClient.isValid() && !sharedClient.equals(thisFlexClient))
List sharedClientFlexSessions = sharedClient.getFlexSessions();
for (Iterator iter3 = sharedClientFlexSessions.iterator() ; iter3.hasNext();)
FlexSession sharedClientFlexSession = (FlexSession)iter3.next();
I will turn on that LCDS logging and will post the results soon. Thanks. By the way, where did you get that very descriptive message for the "<timeout-minutes>" node? The "services-config.xml" file that comes with LCDS 2.5.1 does not even contain a "<flex-client>" node..
Also, offtopic: how to properly insert a code snippet on this forum? I noticed the above sample code got stripped from all its left white spaces, the formatting is now just ugly.
Here,s the log:
[Flex] 10:39:47.328 [DEBUG] [Endpoint.FlexSession] FlexSession created with id '0DB83653B7561285669BB5DC0ABF18E7' for an Http-based client connection.
[Flex] 10:40:03.484 [DEBUG] [Endpoint.FlexSession] FlexSession created with id '759CCC2F-DC0D-C199-21BD-7871C6175538' for a direct RTMP client connection.
[Flex] 10:40:43.687 [DEBUG] [Endpoint.FlexSession] FlexSession with id '0DB83653B7561285669BB5DC0ABF18E7' for an Http-based client connection has been invalidated.
[Flex] 10:40:43.687 [DEBUG] [Endpoint.FlexSession] FlexSession created with id 'C94FDAD845F6F89808AF7691C4E2F5BE' for an Http-based client connection.
[Flex] 10:40:43.703 [DEBUG] [Endpoint.FlexSession] FlexSession created with id '759E4BBE-C70D-996F-A8A4-D96DCBD1799E' for a direct RTMP client connection.
[Flex] 10:40:43.703 [DEBUG] [Endpoint.FlexSession] FlexSession with id '759CCC2F-DC0D-C199-21BD-7871C6175538' for a direct RTMP client connection has been invalidated.
The test case steps:
- login (HTTP session was created, RTMP session was created)
- logout -> (both sessions are invalidated, a new HTTP one is created) the login page is now shown in browser
- login again - here I got the error trying to work with the FlexClient object in a RTMP request. There is a new RTMP session created, but it has no FlexClient associated. FlexContext.getFlexClient() returns the old, invalidated Flexclient object, whicxh has 0 (zero) Flex sessions associated.
Can you do a quick test for me? Can you also try disconnect rtmp channel after logout? I think it may help
I tried this early in the morning (disconnecting the DataService from the Flex client, using the disconnect() ActionScript call), and it worked, as you predicted. Thanks for the tip. Still I don't know what the client-side implications are with the managed data, should I also do something specific with the ArrayCollection objects this DataService used to manage, or nothing needs to be done on this matter?
Should we consider what I described in previous posts on this topic a bug?
Not sure this is a bug or not. I'll discuss it with dev, but I agree with you invalidate the flexclient should also destroy it.
"should I also do something specific with the ArrayCollection objects this DataService used to manage, or nothing needs to be done on this matter?"
I am not quite sure what the situation is. When user logs out, should the application close all services and release all the collections?
Yes, on Logout all the server resources (including the managed data) need to be released/cleared. So for instance, the ArrayCollection object used to be filled with managed data needs to be emptied. I noticed explicitly calling removeAll() for this collection after disconnecting the data service won't work, an error is being thrown.
I think you should use the dataservice.release() or dataservice.releaseCollection(collection, true) before ds.logout
Thanks, so as a recap, the following calls need to be done in this case, in this order:
ds.release(); // to release everything that's managed by this service
ds.disconnect(); // to disconnect the RTMP link to the server
ds.logout(); // to logout the destination for all the ds instances used by this client
Correct? Thank you..
I think the logout should go before rtmp disconnect.