Skip to main content
March 5, 2010
Answered

FMS auto check/trigger connection for clients

  • March 5, 2010
  • 2 replies
  • 4793 views

Hi:  

      This is my second request since last time I have got huge help form SE_0208, thanks man, thanks forum!

      I am using FMS accept a RTMP stream from Wowza and played by Flash player, steps like:

         1.Wowza publish rtmp stream. (very stable can be played by Flash players 7*24 hours.)

         2.Instruct FMS accept rtmp stream:

             a.  create application folder named “Live2”
             b.  copy all files form install dir\samples\applications\live
             c.  enter server codes into main.asc

var nc;

var myStream;

application.onAppStart = function(){

     nc = new NetConnection();

     myStream = Stream.get("foo"); 

     nc.onStatus = function(info){

               if(info.code == "NetConnection.Connect.Success"){

                    myStream.play("livestream",-1,-1,true,nc);   

               }

     }

     nc.connect("rtmp://www.remotertmpserver.com:1935/live"); 

}

   3. reload application, FMS can publish correctly.

      Problem is that FMS publishing always goes down, clients connected in LAN within Giga speed, Wowza output rtmp stream is very stable and

      can be played by Flash players 7*24 hours.Only one thing need to do is by single click the button :‘’Reload this application” in the fms_admin

      Console, then everything will be ok, FMS can resume for publishing.

     Guys, I have lots thing to do and can’t setting in fort of the FMS server all day to monitor.
     Any way I can do to make FMS auto check/trigger connection for clients instead of manual clicking  “Reload this application” ?

Thanks advance

    This topic has been closed for replies.
    Correct answer Janaki Lakshmikanthan

    Hi,

    I didnt get the problem. But will give it a try.

    You have application 'live' in wowza and application 'live2' in FMS right?

    1. Is your wowza server stops publishing but the connection from live2 to live app is still maintained? Then when the publisher starts publishing the stream at wowza, subscriber of live2 will get the stream, until then live2 subscriber will be in wait mode.

    2. Is the connection between wowza and fms is broken? Then you can initate the connection once again once the connection is broken. Pls modify the code at live2 as..

    application.onAppStart = function(){

         nc = new NetConnection();

         myStream = Stream.get("foo");

         nc.onStatus = function(info){

                     if(info.code == "NetConnection.Connect.Success"){

                           myStream.play("livestream",-1,-1,true,nc);   

                      }

                      else  if(info.code == "NetConnection.Connect.Closed"){

                           nc.connect("rtmp://www.remotertmpserver.com:1935/live");                  

                         }

          }

          nc.connect("rtmp://www.remotertmpserver.com:1935/live"); 

    }

    Let me know, if this this not the case

    Regards,

    Janaki L

    2 replies

    Adobe Employee
    March 5, 2010

    I really have no idea why your publishing stops but like i said before that would still be grey area as your set up is not ideal set up in FMS perspective (please don't mind me saying that but I suppose you will agree with me )

    Now please do what Janaki has suggested to see what is happening , whether connection is dropping or something else.

    I would suggest you to do one thing for this: Call a function periodically using setInterval and trace out myStream.time. If you find that its not increasing that means nothing is flowing out of the stream, meaning no data might be coming to it.

    Code :

    var intervalID  (put this after mysteam definition)

    intervalID  = setInterval(printTime,5000);   //put this after myStream.play statement , will be called after 5 seconds each

    function printTime(){

         trace("Stime:"+ myStream.time);

    }

    Now for the question you asked before: auto check or trigger

    I know its not best solution , but you can do onething:

    Write another application on FMS, which basically does reload of your publishing application periodically using Admin API commands

    Say now if you feel say after every 30 minutes publishing seem to stop , you can write following code in you reload application:

    Create main.asc with below code and say name the application as "reloadPublish".

    var admin_nc;

    var intervalID;

    application.onAppStart = function(){

         admin_nc = new NetConnection();

         admin_nc.onStatus = function(info) {

              if (info.code == "NetConnection.Connect.Success"){

                   intervalID = setInterval(reloadApp,1800000)

              }

         }

         admin_nc.connect("rtmp://<server-ip>:1111/admin","admin","admin");

    }

    function Result() {

          this.onResult = function(info) {

               for(i in info){

                   trace(info); 

                }

         }

    }

    function reloadApp(){

         admin_nc.call("reloadApp",new Result(),"publishApp/_definst_");   //where publishApp is your app name of Publishing app - which you wrote before

    }

    Just load this application using Admin Console or just make dummy connection from Flash Player client , onAppStart will get triggered and it will take care of reloading app after 30 minutes.

    let me know if this works.

    March 6, 2010

    HISE

        Nice to meet you again..sorry for delayed response. It’s great news that Janaki’s code works as expected! This code check and monitor the connection for source stream, when I restart or republish in Wowza, FMS can always trigger or initiate by itself and get work properly.

    Unfortunately I didn’t figure out how to realize FMS API “auto re-load application” through the code you kindly created for me, forgive my stupid base. Do you know , I have gradually understand that you have said: “I know it’s not best solution”, periodically trigger or reload application from FMS can cause conscious interception in live channel streaming, probably other approaches could be considered,

    I notice error message in log file of VLC which software I used to get TS stream from DVB-s device:

       Stream_out_transcode stream out debug: drift is too high,resetting master sync

       ts demux warning: lost synchro

       ts demux : skipping 80 bytes of garbage

       ts demux : discontinuity received 0x9 instead of 0xc

       ts demux warning : invalid header

    I am seeking other type of DVB-s card or debug VLC to find out root cause in order to get rid off this error …Any progress would be posted

    guys thanks a lot,you are the best!

    caraboolee

    Adobe Employee
    March 9, 2010

    In your last post you had commented something like this:"actually as far as I know FMS can only accept live streaming by FMLE" - I suppose that's not the case. Please check this page : - http://www.adobe.com/products/flashmediaserver/fmsp/encoding.html - see if helps you , I suppose if you can get one of these encoding solution take your feed and directly publish to FMS rather then redirecting it via Wowza. Hope this is helpful

    Janaki Lakshmikanthan
    Adobe Employee
    Janaki LakshmikanthanCorrect answer
    Adobe Employee
    March 5, 2010

    Hi,

    I didnt get the problem. But will give it a try.

    You have application 'live' in wowza and application 'live2' in FMS right?

    1. Is your wowza server stops publishing but the connection from live2 to live app is still maintained? Then when the publisher starts publishing the stream at wowza, subscriber of live2 will get the stream, until then live2 subscriber will be in wait mode.

    2. Is the connection between wowza and fms is broken? Then you can initate the connection once again once the connection is broken. Pls modify the code at live2 as..

    application.onAppStart = function(){

         nc = new NetConnection();

         myStream = Stream.get("foo");

         nc.onStatus = function(info){

                     if(info.code == "NetConnection.Connect.Success"){

                           myStream.play("livestream",-1,-1,true,nc);   

                      }

                      else  if(info.code == "NetConnection.Connect.Closed"){

                           nc.connect("rtmp://www.remotertmpserver.com:1935/live");                  

                         }

          }

          nc.connect("rtmp://www.remotertmpserver.com:1935/live"); 

    }

    Let me know, if this this not the case

    Regards,

    Janaki L

    March 5, 2010

    HI, Janaki:


    Thanks ,I have tried your code, seems no change.


    I understand your point, but I can’t see the connection  between FMS and Wowza in fms admin Console. For example, FMS accept rtmp  stream form Wowza and re-publishing, if there is one flash player  connected, then I can only see 1 connection (total connection=1).  However, when the FMS publishing goes down , I check Wowza’s log, the  connection between FMS still exist.



    Follow  your suggestion , I republish stream in Wowza side, restart Wowza  server, all failed to trigger FMS, the only way is by  click “Reload this application”. In other word, FMS seems not works as a  client connect to Wowza, because I have found that  flash player can  automatically play if the stream form Wowza was republished.



    So, when using FMS to re-stream form Wowza(or others),  FMS needs to originally and periodically check the status of source  stream, is it correct?


    Janaki Lakshmikanthan
    Adobe Employee
    Adobe Employee
    March 5, 2010

    Hi,

    The reason why you dont see the number of connection as 1 when ur FMS connects to wowza is that the "connected' property is counted for the clients that are connected to FMS and not for the connections initiated from FMS. Hence when you connect a flash client your FMS shows connected = 1. So what you are seeing in admin console is expected. You should be able to see the connected counted at wowza server which was connected by FMS and not at the FMS side.

    In the server side code We are trying to initiate the connection when it gets closed. Can you modify the code so that we invoke nc.connect() even if we get "NetConnection.Connect.Failed" like below...

    else  if(info.code == "NetConnection.Connect.Closed" || "NetConnection.Connect.Failed"){

          nc.connect("rtmp://www.remotertmpserver.com:1935/live");                  

    }