Skip to main content
Known Participant
October 23, 2011
Question

publishing stream to remote FMS

  • October 23, 2011
  • 1 reply
  • 1725 views

Hello,

I have followed this link to republish my local stream to other local application instance : http://help.adobe.com/en_US/FlashMediaServer/3.5_Deving/WS5b3ccc516d4fbf351e63e3d11a0773d56e-7ffb.html

i have used this script code into main.asc and it is working  :

// Called when the client publishes

application.onPublish = function(client, myStream) {

    trace(myStream.name + " is publishing into application " + application.name);  

    // This is an example of using the multi-point publish feature to republish

    // streams to another application instance on the local server.

    if (application.name == "live/_definst_"){

        trace("Republishing the stream into remote app/anotherinstance");

        nc = new NetConnection();

        nc.connect( "rtmp://localhost/live" );

        ns = new NetStream(nc);

        // called when the server NetStream object has a status

        ns.onStatus = function(info) {

            trace("Stream Status: " + info.code)

            if (info.code == "NetStream.Publish.Start") {

                trace("The stream is now publishing");

            }          

        }

        ns.setBufferTime(2);

        ns.attach(myStream);

        ns.publish( myStream.name, "live" );

    }

}

i have replaced this code :  nc.connect( "rtmp://localhost/live" );   by this one to publish to remote FMS : nc.connect( "rtmp://myremoteserver/live" );  but streaming isn't working on remote FMS

How can make it working remotely ?

Regards,

Morsi

    This topic has been closed for replies.

    1 reply

    Nikhil_Kalyan
    Participating Frequently
    October 23, 2011

    Hi,

    is the connection to the remove server successful ? Add the nc.onStatus handler also , the way it is added for stream, so that you can recieve the status codes for connection.

    Known Participant
    October 23, 2011

    nc.onStatus handler already added on local side

    i have tried with this nc.connect( "rtmp://myremoteserver/live/newInstance" ); the newInstance  has been created but the stream isn't publishing remotely :

    that code displays nothing  :

       ns.onStatus = function(info) {

                trace("Stream Status: " + info.code)

                if (info.code == "NetStream.Publish.Start") {

                    trace("The stream is now publishing");

                }          

    Thanks

    Nikhil_Kalyan
    Participating Frequently
    October 23, 2011

    try making the stream after the connection is established.

    if (application.name == "live/_definst_"){

            trace("Republishing the stream into remote app/anotherinstance");

            nc = new NetConnection();

            nc.connect( "rtmp://localhost/live" );

          nc.onStatus = function(info) {

                trace("Status: " + info.code)

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

                  

               ns = new NetStream(nc);

            // called when the server NetStream object has a status

            ns.onStatus = function(info) {

                trace("Stream Status: " + info.code)

                if (info.code == "NetStream.Publish.Start") {

                    trace("The stream is now publishing");

                }         

            }

            ns.setBufferTime(2);

            ns.attach(myStream);

            ns.publish( myStream.name, "live" );

                }         

    }