Login After BlazeDS Session Timeout

POSTED IN Actionscript, Flex | TAGS : , , March 17, 2009

While I was working on a Flex project, I noticed a weird little quirk.  We’re currently using BlazeDS to connect to the back-end and it keeps pushing new information to the front-end.  However, we have a session timeout set to 15 minutes for security purposes that needs to be handled on the front-end and then let them be able to re-login.

When the user tried to re-login using the consumer, it wouldn’t work.  No errors, no message, nothing.  A nice silent error; great.  There wasn’t a lot of documentation on this phenomenon and the internet didn’t seem to provide any solutions.

After days of getting to know everything I could about the Consumer component, I learned this nice little tidbit:

resubscribeInterval:int [read-write]

The number of milliseconds between resubscribe attempts. If a Consumer doesn’t receive an acknowledgement for a subscription request, it will wait the specified number of milliseconds before attempting to resubscribe. Setting the value to zero disables resubscriptions.

Apparently, the Consumer tries to resubscribe when the connection goes down.  I personally don’t like this logic;  shouldn’t it be up to the developer to handle the event and use the proper logic within that event function? But I digress.

For future reference for anyone out there, if you need to handle the server disconnect event on your own (ie. log back in after a disconnect), make sure you have resubscribeAttempts=”0″ and resubscribeInterval=”0″ set within your consumer.

Loading