2 Replies Latest reply on Nov 12, 2010 4:21 AM by Abhinav Sharma

    StreamingAMF client-to-server-heartbeat

    christoferdutz Level 1



      I am currently developing an application that makes heavy use of Streaming AMF channels. Now I am having some trouble with these channels when the internet-connection is messy.


      Users with bad internet connections have complained, that they don't notice that they have lost the connection and that they only find out as soon as they try to explicitly use the channel (by posting something) then a FaultEvent is fired and the channel is immediately disconnected.


      Is there something like a client-to-server heartbeat that allows the client to check if the connection is still there?



        • 1. Re: StreamingAMF client-to-server-heartbeat
          Abhinav Sharma Level 2

          Hi, You can take advantage of Timer() to do this stuff. May be there some better way to do this.




                    public class TimerExample{
                         public function TimerExample() {
                              var myTimer:Timer = new Timer(5000); //5secs
                              myTimer.addEventListener("timer", timerHandler);
                         //Here the Heartbeat will be checked
                         //This funtion will be called every 5second. Write code here to check connection.
                         public function timerHandler(event:TimerEvent):void {
                              pingServer("ServerName"); // will be coded by you.

                         private function pingServer(serName:String = "default"):void{
                              //write logic here to connect to server and on result dispatch proper event.
                         public function ServerResult(event:Event):void {
                              if(event.name == 'CONNECTED')
                                   //do something
                                   Alert.show(":( OOPss... Connection Lost!!!");

          Hope this would help.


          • 2. Re: StreamingAMF client-to-server-heartbeat
            christoferdutz Level 1

            Hi Abhinav,


            thanks for your response. I was hoping on a counterpart to the server server-to-client-heartbeat setting of the StreamingAmfChannel on the BlazeDS Side. Guess there is no such thing (even if I wonder why). I was hoping to avoid such a solution as you suggested. Perhaps it would feel cleaner for me if I extended BlazeDS for an automatic "heartbeat-response" and create a custom HeartbeatStreamingAMFChannel on the Flex side which internally uses such a Timer-technique.


            Any other suggestions?