0

27.10.2014:这个问题我仍然需要帮助。

我和我的朋友正在尝试通过 SmartFoxServer 托管游戏。他在他的计算机上托管服务器,并已成功将必要的端口 (9339) 端口转发到他的本地 IP。我们已经完成了本指南中的所有内容。根据 SmartFoxServer 通过管理面板和服务器终端窗口的反馈,托管应该是成功的。

但是,当尝试连接到他的公共 IP 时,我收到此错误:

[警告] 安全错误:错误 #2048:违反安全沙箱:文件:无法从 #IP# 加载数据。

跨域.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>

配置文件

<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 字节 [发送]:[警告] 安全错误:错误 #2048:安全沙箱违规:文件:文件目录无法加载数据来自公共主机 IP:9339。[UnloadSWF]文件目录 调试会话终止。调试会话终止。*

4

3 回答 3

0

更改以下行:

<allow-access-from domain="*" t-ports="*"/>

至:

<allow-access-from domain="*" t-ports="*" secure="false" />

如果仍有问题,您可以阅读官方跨域策略文档查看更多详细信息

一些有用的网址

于 2014-10-20T06:07:14.800 回答
0

为了快速获得帮助,我将 stackoverflow 视为最可靠的服务之一,但这次我从其他地方得到了答案。我会在这里重写它。

也许有同样问题的人将来会认为这很有用。

问题毕竟很简单。独立的 Adob​​e Flash Player 会自动拒绝此类连接。但是在浏览器中运行时它可以工作..

于 2014-10-29T02:31:13.280 回答
0

您的保单文件中有错字。

在第 4 行

<allow-access-from domain="*" t-ports="*" secure="false" />

本来应该

<allow-access-from domain="*" to-ports="*" secure="false" />

请注意,您有 t-ports 而不是 to-ports。

来源:跨域策略文件规范。https://www.adobe.com/content/dam/acom/en/devnet/articles/CrossDomain_PolicyFile_Specification.pdf#G3.344406

于 2021-01-01T19:14:30.363 回答