连接到red5服务器时出现NetConnection.Connect.Rejected错误

时间:2012-03-23 19:25:57

标签: flash flex streaming flash-builder

我是flex的新手。我创建了动态网络项目。运行。可在http://localhost:5080/myApp访问。现在我想创建与该应用程序的连接,但我得到了NetConnection.Connect.Rejected。这是我的代码:

import mx.core.UIComponent;
        import mx.events.FlexEvent;

        private var connection:NetConnection;
        private var inStream:NetStream;
        private var outStream:NetStream;


        private var camera:Camera;
        private var microphone:Microphone;


        private var inVideo:Video;
        private var outVideo:Video;


        private var inVideoWrapper:UIComponent;
        private var outVideoWrapper:UIComponent;



        protected function application1_creationCompleteHandler(event:FlexEvent):void
        {
            connection = new NetConnection();
            connection.connect("rtmp://localhost/myApp");
            connection.addEventListener(NetStatusEvent.NET_STATUS, onConnected);

        }

        private function onConnected(event:NetStatusEvent):void
        {
            if(event.info.code == "NetConnection.Connect.Success")
            {
                setupVideo();
            }
        }

        private function setupVideo():void
        {
            camera = Camera.getCamera();
            microphone = Microphone.getMicrophone();

            outStream = new NetStream(connection);
            outStream.attachCamera(camera);
            outStream.attachAudio(microphone);
            outStream.publish("Radislav");

            outVideo = new Video();
            outVideo.attachCamera(camera);

            inStream = new NetStream(connection);
            inStream.play("Radislav");

            inVideo = new Video();
            inVideo.attachNetStream(inStream);


            outVideoWrapper = new UIComponent;
            outVideoWrapper.addChild(outVideo);
            addElement(outVideoWrapper);


            inVideoWrapper = new UIComponent;
            inVideoWrapper.addChild(inVideo);
            addElement(inVideoWrapper);

            inVideoWrapper.move(400,0);

        }

1 个答案:

答案 0 :(得分:1)

长话短说 - 您需要connection.connect()来电中的第二个参数。但是您想要阅读服务器日志(red5 / jvm)以获取更多详细信息。如果您没有看到日志,请在此处说明如何让服务器编写日志:http://avchathq.com/blog/missing-red5-log-files-where-are-they/