2 Replies Latest reply on Nov 29, 2010 10:44 PM by Mykola3296

    Stream reconnect and NetConnection.Connect.IdleTimeOut

    Mykola3296 Level 2

      Hello!

       

      I have a question regarding stream reconnect feature in OSMF 1.5.

       

      Is it intended to cope with NetConnection.Connect.IdleTimeOut of FMS disconnecting clients after some time of inactivity?

      I've tryied the feature but it did not work.

       

      What I did is:

       

      1) Created MediaPlayer, MediaController etc.

      2) Created a streaming video

      3) Started playback

      4) Paused playback

       

      After 2 minutes (idle timeot set in FMS) the connection was closed with NetConnection.Connect.IdleTimeOut message with no reconnect attempt.

      Here is the message log:

      Thu Nov 25 2010 09:45:34 AM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Pause.Notify

      Thu Nov 25 2010 09:45:34 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Pause.Notify

      Thu Nov 25 2010 09:45:34 AM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Buffer.Flush

      Thu Nov 25 2010 09:45:34 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Buffer.Flush

      Thu Nov 25 2010 09:46:15 AM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Play.Stop

      Thu Nov 25 2010 09:46:15 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Play.Stop

      Thu Nov 25 2010 09:46:15 AM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Buffer.Flush

      Thu Nov 25 2010 09:46:15 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Buffer.Flush

      --- We are in pause state

      Thu Nov 25 2010 09:47:42 AM [INFO] [org.osmf.net.NetStreamLoadTrait] NetConnection.Connect.IdleTimeOut

      Thu Nov 25 2010 09:47:42 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetConnection.Connect.IdleTimeOut

      Thu Nov 25 2010 09:47:42 AM [INFO] [org.osmf.net.NetStreamLoadTrait] NetConnection.Connect.Closed

      Thu Nov 25 2010 09:47:42 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetConnection.Connect.Closed

      Thu Nov 25 2010 09:47:42 AM [DEBUG] [org.osmf.net.NetLoader] Stream reconnect: connection failed, bufferLength is 44.098

      Looking into NetLoader I've found the following code in onNetStatus handler:

       

      case NetConnectionCodes.CONNECT_IDLE_TIME_OUT:
           fmsIdleTimeoutReached = true;
           break;
      case NetConnectionCodes.CONNECT_CLOSED:
      case NetConnectionCodes.CONNECT_FAILED:
           CONFIG::LOGGING
           {     
           if (loadTrait.netStream != null)
           {
                logger.debug(STREAM_RECONNECT_LOGGING_PREFIX+"connection failed, bufferLength is "+loadTrait.netStream.bufferLength);
           }
           else
           {
                logger.debug(STREAM_RECONNECT_LOGGING_PREFIX+"connection failed, bufferLength is zero");
           }
           }
           if (loadTrait.loadState == LoadState.READY && !reconnectHasTimedOut && !fmsIdleTimeoutReached) 
           {
           reconnectTimer.start();
                                              
           // If our buffer is empty when the connection closes, then
           // we must start the timeout Timer now, since we won't get
           // a Buffer.Empty event later (FM-1076).  Note that we check
           // for this in two ways, since bufferLength might not be
           // zero when we get the Buffer.Empty event.
           if (bufferIsEmpty || loadTrait.netStream.bufferLength == 0 || streamIsPaused)
           {
                if (timeoutTimer != null)
                {
                timeoutTimer.start();
                }
                else
                {
                reconnectHasTimedOut = true;
                     
                // Clean up
                setupReconnectTimer(false);
                setupNetConnectionListeners(false);
                setupNetStreamListeners(false);
                setupTimeoutTimer(false);
                }
           }
           }
           else
           {
           // Clean up
           setupReconnectTimer(false);
           setupNetConnectionListeners(false);
           setupNetStreamListeners(false);
           setupTimeoutTimer(false);
           }
           break;
      
       
      

      Following the events and

      if (loadTrait.loadState == LoadState.READY && !reconnectHasTimedOut && !fmsIdleTimeoutReached) 
      

      construct we get NO reconnect on idle timeout from FMS.

       

      As an experiment, I've tried to change the clause and removed the fmsIdleTimeoutReached negation in the above clause:

      if (loadTrait.loadState == LoadState.READY && !reconnectHasTimedOut && fmsIdleTimeoutReached) 
      

      to try to reconnect upon idle. But in this case I get an RTE. Here is the event flow and error description:

      Thu Nov 25 2010 10:06:03 AM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Pause.Notify

      Thu Nov 25 2010 10:06:03 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Pause.Notify

      Thu Nov 25 2010 10:06:03 AM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Buffer.Flush

      Thu Nov 25 2010 10:06:03 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Buffer.Flush

      Thu Nov 25 2010 10:06:44 AM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Play.Stop

      Thu Nov 25 2010 10:06:44 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Play.Stop

      Thu Nov 25 2010 10:06:44 AM [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Buffer.Flush

      Thu Nov 25 2010 10:06:44 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetStream.Buffer.Flush

      Thu Nov 25 2010 10:07:51 AM [INFO] [org.osmf.net.NetStreamLoadTrait] NetConnection.Connect.IdleTimeOut

      Thu Nov 25 2010 10:07:51 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetConnection.Connect.IdleTimeOut

      Thu Nov 25 2010 10:07:51 AM [INFO] [org.osmf.net.NetStreamLoadTrait] NetConnection.Connect.Closed

      Thu Nov 25 2010 10:07:51 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetConnection.Connect.Closed

      Thu Nov 25 2010 10:07:51 AM [DEBUG] [org.osmf.net.NetLoader] Stream reconnect: connection failed, bufferLength is 44.031

      Thu Nov 25 2010 10:07:52 AM [DEBUG] [org.osmf.net.NetLoader] Stream reconnect: About to create a new NetConnection...

      Thu Nov 25 2010 10:07:52 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: Calling reconnectNetConnection to try to reconnect...

      Thu Nov 25 2010 10:07:52 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: onNetStatus: NetConnection.Connect.Success

      Thu Nov 25 2010 10:07:52 AM [INFO] [org.osmf.net.NetLoader] Stream reconnect: FMS version 4,0,0,1121

      Error: Error #2154: The NetStream Object is invalid. This may be due to a failed NetConnection.

           at flash.net::NetStream/play2()

           at org.osmf.net::NetLoader/reconnectStream()[C:\Work\Workspace\OSMF\org\osmf\net\NetLoader.a s:405]

           at org.osmf.net.rtmpstreaming::RTMPDynamicStreamingNetLoader/reconnectStream()[C:\Work\Works pace\OSMF\org\osmf\net\rtmpstreaming\RTMPDynamicStreamingNetLoader.as:130]

           at Function/org.osmf.net:NetLoader/private:setupStreamReconnect/org.osmf.net:onNetStatus()[C :\Work\Workspace\OSMF\org\osmf\net\NetLoader.as:601]

      So, is the reconnect feature is supposed to deal with idle timeout?

      Or am I doing it wrong way?

       

      By the way, here is a new connection creation function that is used to create a "replacement" connection:

      protected function createReconnectNetConnection():NetConnection
      {
           return new NetConnection();
      }
      

      There is no connection factory used as in the function that starts RTMP in the same class:

      private function startLoadingRTMP(loadTrait:LoadTrait):void
      {
           addPendingLoad(loadTrait);
                     
           netConnectionFactory.create(loadTrait.resource as URLResource);
      }
      

      So we would not get a connection factory notification on reconnect anyway if you are interested in it. And the connection sharing goes the same way (no connection sharing after reconnect).

       

      Thank you!