LCDS 2.5 RTMP mx:Consumer not able to resubscribe after disconnect (ColdFusion 8)
This post does not apply to most readers but just in case someone else runs into this bug, they will find some answers in this post and avoid wasting a lot of time hunting in search engines as I did. If you don’t run ColdFusion 8 and/or LCDS 2.5.1 using RTMP messaging, it doesn’t apply to you.
ColdFusion 8.x comes bundled with LiveCycle Data Services 2.5.1 (2 versions behind the current 3.0). If you are using this combo for publish/subscribe messaging with RTMP (only available in LCDS, not in BlazeDS), you need to be aware of a bug. If in your Flex code you create a consumer (<mx:Consumer id=”c” …) and then do a c.subscribe(), all is well and the consumer will receive messages as expected. However, if your client app becomes disconnected, even for a split second, it will not be able to resubscribe. In my particular case I had c.resubscribeInterval=5000 and c.resubscribeAttempts=-1 which should enable auto-resubscribing for the consumer in case the connection is broken. In LCDS 2.6.1 and 3.0 this works perfectly. However, in 2.5.1 there is a bug and your consumer will become deaf because it is basically resubscribing to an invalid session that the server failed to clear after the disconnect. Even a c.unsubscribe()/c.disconnect()/c.subscribe() doesn’t put things back in working order. The code runs fine with no unusual events so everything appears to be re-subscribed. Even the c.subscribed boolean property will be true… but the consumer is never going to receive another message. The workaround is extremely hackish – you have to send a garbage message (that will not be received by the broken consumer). The server will try to broadcast the published message to its consumers and discover that the old session is invalid and then clean it up. After this occurs, you can do a c.subscribe() and be back in business. However, this is not as easy as it sounds because there are timing issues and you can’t attempt to disconnect/resubscribe until the garbage message is acknowledged. You end up with code full of temporary event listeners, timers, etc. which goes way beyond an acceptable hack IMO.
This bug is only with LCDS 2.5.1 RTMP-based messaging.
The best solution is to upgrade to ColdFusion 9 and install LiveCycle Data Services 2.6.1 (instructions here) if you need RTMP messaging. This will handle disconnects/resubscribes perfectly. If you are running LCDS 2.5.1 without ColdFusion, you should upgrade to 3.0.
Currently LCDS 3.0 is not supported with ColdFusion 9 but that will change in the next version of ColdFusion. LCDS 3.0 introduces additional pub/sub messaging features including reliable messaging, message throttling and other goodies. More on this topic soon.
Lastly – if you are running ColdFusion 8, it’s time to upgrade anyways! 🙂