四、注意事项
通常新手在学习FMS的时候都会遇到一个问题,那就是通过NetConnection连接FMS服务器的时候,连接状态总是返回 “NetConnection.Connect.Rejected”这样的状态结果,然后接着还有会有一个 “NetConnection.Connect.Failed”状态,是什么原因造成这样的错误的呢?
第一个错误从本文实例中你可以得到,是访问FMS服务器的权限问题,如果FMS没有开设足够的访问权限,通常在访问FMS的客户端都会接受到这样一个异 常状态。第二个错误又是怎么产生的呢?这还是又访问权限引起,当客户端没有主够的权限访问FMS服务器,就将返回 “NetConnection.Connect.Rejected”状态并自动断开与FMS服务器的连 接,“NetConnection.Connect.Failed”状态本身是由于连接服务器失败产生,而这里是因为权限问题而引发的。
前几天很多朋友就在问我这个问题,怎么来解决这个问题呢?如果你是一个技术专研者,如果又你赶兴趣的技术在你面前,你首先会做什么?查看官方提供的文 档?实例代码?还是什么? OK,其实要解决这个问题很简单,在FMS服务器安装好后的目录下有一个"applications"目录,里面有两个FMS默认安装的FMS服务器 (live和vod),随便打开一个默认安装然后打开里面的"readme.txt"文件会看到下面的字样:
================================================================
Deploying an unsigned vod service
================================================================
1. Create a new folder in the {FMS-Install-Dir}/applications folder.
2. If you are replacing the default Adobe signed live service, back up
the following files:
* main.far
* Application.xml
* allowedHTMLDomains.txt
* allowedSWFDomains.txt
3. Copy files from {FMS-Install-Dir}/samples/applications/vod to the directory you created in step 1.
现在你知道怎么解决上面出现的问题了吗??将这main.far、Application.xml、allowedHTMLDomains.txt和 allowedSWFDomains.txt这四个文件复制到你创建的FMS服务器目录下就解决了,运行上面的实例程序,然后可以通过FMS的管理控制台 查看到详细的连接信息。
我通常是使用的FMS安装目录下的fms_adminConsole.swf 来查看连接信息,也可以使用FMSfms_adminConsole.htm查看。
服务器连接设置
- <SPAN style= "COLOR: #c0c0c0" ><SPAN><SPAN><SPAN>application.onConnect=function(client,permission){
- trace(permission);
- if(permission == "admin" ){
- //服务器同意连接
- this.acceptConnection(client)
- }else{
- //服务器拒绝连接
- //this.rejectConnection(client);
- application.rejectConnection(client, {msg: "server refuse " +permission+ " connecting !" });
- }
- }
- </SPAN>
- </SPAN>
- </SPAN>
- </SPAN>
application.onConnect=function(client,permission){
trace(permission);
if(permission == "admin"){
//服务器同意连接
this.acceptConnection(client)
}else{
//服务器拒绝连接
//this.rejectConnection(client);
application.rejectConnection(client, {msg:"server refuse "+permission+" connecting !"});
}
}
- <SPAN style= "COLOR: #c0c0c0" ><SPAN><SPAN><SPAN>myNetConnection.connect(serverApp, "admin" );</SPAN>
- </SPAN>
- </SPAN>
- </SPAN>
myNetConnection.connect(serverApp, "admin");
- <SPAN style= "COLOR: #c0c0c0" ><SPAN><SPAN><SPAN>switch(evt.info.code)
- {
- case "NetConnection.Connect.Success" :
- trace( "成功连接FMS服务器!" );
- break;
- case "NetConnection.Connect.Rejected" :
- /* 注意这里,服务器拒绝你的情况,如果遭到拒绝,将会调用两次mync.onStatus,
- 第一次 "NetConnection.Connect.Rejected" 第 2 次 "NetConnection.Connect.Closed" */
- trace( "遭到服务器拒绝" );
- trace( "服务器返回信息:" + evt.info.application.msg);
- break;
- case "NetConnection.Connect.InvalidApp" :
- trace( "指定的应用程序名称没有找到" );
- break;
- case "NetConnection.Connect.Failed" :
- trace( "连接失败!" );
- break;
- case "NetConnection.Connect.AppShutDown" :
- trace( "服务器端应用程序已经关闭(由于资源耗用过大等原因)或者服务器已经关闭!" );
- break;
- case "NetConnection.Connect.Closed" :
- trace( "与FMS的连接中断!" );
- break;
- }
- </SPAN>
- </SPAN>
- </SPAN>
- </SPAN>
switch(evt.info.code)
{
case "NetConnection.Connect.Success":
trace("成功连接FMS服务器!");
break;
case "NetConnection.Connect.Rejected":
/* 注意这里,服务器拒绝你的情况,如果遭到拒绝,将会调用两次mync.onStatus,
第一次"NetConnection.Connect.Rejected"第2次"NetConnection.Connect.Closed" */
trace("遭到服务器拒绝");
trace("服务器返回信息:" + evt.info.application.msg);
break;
case "NetConnection.Connect.InvalidApp":
trace("指定的应用程序名称没有找到");
break;
case "NetConnection.Connect.Failed":
trace("连接失败!");
break;
case "NetConnection.Connect.AppShutDown":
trace("服务器端应用程序已经关闭(由于资源耗用过大等原因)或者服务器已经关闭!");
break;
case "NetConnection.Connect.Closed":
trace("与FMS的连接中断!");
break;
}
(thanks : http://www.51as.com/fms/fms3jiaochen.html )
相关资料一大把:
Flash Media Server 入门教程
http://www.nshen.net/blog/article.asp?id=509
Flash Media Server 起步(2)连接
http://www.nshen.net/blog/article.asp?id=394
Flash Media Server 起步(3)远程共享
http://www.nshen.net/blog/article.asp?id=395
Flash Media Server 起步(4)视频,流。。。
http://www.nshen.net/blog/article.asp?id=397
Flash Media Server 起步(5)连接的一些细节
http://www.nshen.net/blog/article.asp?id=401
Flash Media Server 起步(6)写个简单的聊天室
http://www.nshen.net/blog/article.asp?id=403
Flash Media Server 起步(9)在线列表。。
http://www.nshen.net/blog/article.asp?id=409
Flash Media Server 起步(10)中文编码问题
http://www.nshen.net/blog/article.asp?id=414
Flash Media Server 起步(11)判断影片结束
http://www.nshen.net/blog/article.asp?id=415
http://www.cnblogs.com/aierong/archive/2009/01/09/flex_fms_chat.html