0

27.10.2014:對於這個問題,我仍然非常需要幫助。ActionScript SmartFoxServer無法連接

我和朋友正試圖通過SmartFoxServer託管遊戲。他將服務器託管在他的計算機上,並已成功將必要的端口(9339)轉發到他的本地IP。我們已經完成了this guide。根據SmartFoxServer通過管理面板和服務器終端窗口的反饋,託管應該是成功的。

但是,試圖連接到他的公網IP的時候,我得到這個錯誤:

[WARN]安全錯誤:錯誤#2048:安全沙箱衝突:文件: 不能加載從#IP#數據。

的crossdomain.xml

<?xml version="1.0"?> 
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"> 
<cross-domain-policy> 
    <allow-access-from domain="*" t-ports="*" secure="false" /> 
</cross-domain-policy> 

的config.xml

<ServerSetup> 

    <ServerIP>10.0.0.8</ServerIP> 
    <ServerPort>9339</ServerPort> 

    <AutoSendPolicyFile>true</AutoSendPolicyFile> 
    <MaxUserIdleTime>300</MaxUserIdleTime> 

    <!-- Server Variables limits (-1 = unlimited) --> 
    <MaxRoomVars>-1</MaxRoomVars> 
    <MaxUserVars>-1</MaxUserVars> 

    <AntiFlood active="false"> 
     <MinMsgTime tolerance="5">1000</MinMsgTime> 
     <MaxRepeatedMessages>3</MaxRepeatedMessages> 
     <WarningsBeforeKick>2</WarningsBeforeKick> 
     <WarningMessage><![CDATA[No flooding allowed!)]]></WarningMessage> 
     <KickMessage><![CDATA[You've been warned! No flooding! Now you're kicked]]></KickMessage> 
     <BanMessage><![CDATA[Stop Flooding!! You're being banned]]></BanMessage>    
     <BanAfter timeSpan="1">3</BanAfter> 
    </AntiFlood> 

    <BadWordsFilter active="false"> 
     <FilterMode>filter</FilterMode> <!-- REMOVE or FILTER --> 
     <StripCharacters><![CDATA[,.;:_!$%&/#*-+]]></StripCharacters> 
     <Warnings>true</Warnings> 
     <FilterRoomNames>true</FilterRoomNames> 
     <FilterUserNames>true</FilterUserNames> 
     <WarningsBeforeKick>3</WarningsBeforeKick> 
     <WarningMessage><![CDATA[No swearing!)]]></WarningMessage> 
     <KickMessage><![CDATA[You've been warned! No Swearing! Now you're kicked]]></KickMessage> 
     <BanMessage><![CDATA[Stop Swearing! You're being banned!]]></BanMessage>  
     <BanAfter timeSpan="1">3</BanAfter> 

     <BadWordsList> 
      <badWord>motherfucker</badWord>    
      <badWord>dickhead</badWord> 
      <badWord>asshole</badWord> 
      <badWord>shithead</badWord> 
      <badWord>shit</badWord> 
      <badWord>fucking</badWord> 
      <badWord>fuck</badWord> 
      <badWord>dickhead</badWord> 
      <badWord>bastard</badWord> 
      <badWord>nigger</badWord> 
      <badWord>idiot</badWord> 
      <badWord>bitch</badWord> 
     </BadWordsList> 
    </BadWordsFilter> 

    <BanCleaning>auto</BanCleaning> 
    <BanDuration>1800</BanDuration> <!-- 30 min --> 
    <BannedLoginMessage>You have been banned!</BannedLoginMessage> 

    <OutQueueThreads>1</OutQueueThreads> 
    <ExtHandlerThreads>1</ExtHandlerThreads> 
    <MaxWriterQueue>50</MaxWriterQueue> 
    <MaxIncomingQueue>8000</MaxIncomingQueue> 
    <DeadChannelsPolicy>strict</DeadChannelsPolicy> 

    <MaxMsgLen>4096</MaxMsgLen> 

    <LogMaxSize>5000000</LogMaxSize> 
    <LogMaxFiles>5</LogMaxFiles> 

    <!-- 
     Available options are: 

     FINEST 
     FINER 
     FINE 
     CONFIG 
     INFO 
     WARNING 
     SEVERE 

    --> 
    <FileLoggingLevel>WARNING</FileLoggingLevel> 
    <ConsoleLoggingLevel>INFO</ConsoleLoggingLevel> 

    <AdminLogin>sfs_admin</AdminLogin> 
    <AdminPassword>sfs_pass</AdminPassword> 

    <AdminAllowedAddresses> 
     <AllowedAddress>*.*.*.*</AllowedAddress> 
    </AdminAllowedAddresses> 

    <IpFilter>0</IpFilter> 

    <!-- Enable/Disable remote zone info --> 
    <EnableZoneInfo>false</EnableZoneInfo> 

</ServerSetup> 



<!-- 
    Zones Configuration. 
--> 
<Zones> 
    <Zone name="multiChat"> 
     <Rooms> 
      <Room name="Main Lobby" maxUsers="50" isPrivate="false" isTemp="false" autoJoin="true" /> 
     </Rooms> 
    </Zone> 
</Zones> 

的ActionScript 3/Flash文件

import flash.events.SecurityErrorEvent; 
import flash.system.Security; 
import it.gotoandplay.smartfoxserver.* 
import flash.events.MouseEvent; 

connect_btn.addEventListener(MouseEvent.CLICK, initiateConnection); 

function initiateConnection(evt:MouseEvent):void 
{ 
    // ip_text.test = public IP address of server host machine 
    // int(port_text.text) = 9339 
    // zone_text.text = "multiChat" 
    // name_text.text = "testUser" 

    status_text.text = "Connecting to " + ip_text.text + "..."; 
    var policyLoad:String = "xmlsocket://" + ip_text.text + ":" + port_text.text; 
    Security.loadPolicyFile(policyLoad) 

    var smartFox:SmartFoxClient = new SmartFoxClient(true) 
    smartFox.addEventListener(SecurityErrorEvent.SECURITY_ERROR, sandboxHandler) 
    smartFox.addEventListener(SFSEvent.onConnection, onConnectionHandler) 
    smartFox.connect(ip_text.text, int(port_text.text)) 

    smartFox.addEventListener(SFSEvent.onLogin, onLoginHandler) 
    smartFox.addEventListener(SFSEvent.onRoomListUpdate, onRoomListUpdateHandler) 

    smartFox.login(zone_text.text, name_text.text, "") 
} 

function onConnectionHandler(evt:SFSEvent):void 
{ 
    if (evt.params.success) 
     status_text.appendText("Connection successful \n"); 
    else 
     status_text.appendText("Connection failed \n"); 
} 



function onLoginHandler(evt:SFSEvent):void 
{ 
    if (evt.params.success) 
     status_text.appendText("Successfully logged in as " + evt.params.name + "\n"); 
    else 
     status_text.appendText(status_text.text + "Zone login error; the following error occurred: " + evt.params.error + "\n"); 
} 

function onRoomListUpdateHandler(evt:SFSEvent):void 
{ 
    // Dump the names of the available rooms in the "simpleChat" zone 
    for (var r:String in evt.params.roomList) 
     status_text.appendText(status_text.text + evt.params.roomList[r].getName() + "\n"); 
    //smartFox.joinRoom(10) 
} 

function sandboxHandler(evt:SecurityErrorEvent):void 
{ 
    status_text.appendText("Sandbox Error/Flash Security Error Event"); 
} 

輸出:

*試圖啓動並使用URL 目錄文件 [SWF] 目錄文件器連接到播放器 - 92561個字節解壓後 [發送]: [WARN]安全錯誤:錯誤#2048:安全沙箱衝突:文件:目錄中的文件可以不加載來自PUBLIC HOST IP:9339的數據。 [UnloadSWF] 目錄的文件 調試會話終止。 調試會話終止。*

+0

您能否顯示您的crossdomain.xml? – gabriel 2014-10-17 09:10:17

+0

完成。我還添加了配置文件和Flash文件。 – user3257755 2014-10-23 12:11:25

回答

0

我爲了得到迅速幫助視爲計算器最可靠的服務之一,但這次我從別的地方得到了答案。我會在這裏重寫它。

也許某個具有相同問題的人會認爲這將在未來有用。

問題畢竟很簡單。獨立的Adobe Flash Player會自動拒絕這種連接。然而,它在瀏覽器中運行時會起作用。