【问题标题】:AS3 + PHP Socket Server Connection IssuesAS3 + PHP Socket 服务器连接问题
【发布时间】:2013-07-26 20:45:15
【问题描述】:

我的问题与这里提出的问题有关 - Flash socket server only works on local machine

我的 flash 应用程序在我的本地机器上的本地 apache 服务器上运行良好,但是当我尝试连接到我的 Amazon 服务器上运行的 PHP 套接字服务器时,它无法连接。我认为我的问题与跨域文件有关,但我找不到太多关于它的信息。

这是我的代码。

AS3:

var host:String = "x.x.x.x"; // substituted for actual IP of website
var port:uint = 9999;

Security.allowDomain("*"); 
Security.loadPolicyFile("http://www.example.com/crossdomain.xml"); // substituted for actual domain name

socket.connect(host, port);

PHP:

$ip = '0.0.0.0';
$port = 9999;

跨域:

<cross-domain-policy>
  <site-control permitted-cross-domain-policies="master-only"/>
    <allow-access-from domain="*.example.com"/>
</cross-domain-policy>

如果我需要添加任何进一步的信息,请告诉我。

谢谢

【问题讨论】:

    标签: php actionscript-3


    【解决方案1】:

    查看我的回答Annoying Error #2048: Security sandbox violation from localhost,您需要在 843 端口或连接端口 (9999) 上设置套接字策略服务器,而不是 http 传递的 xml。

    更新: 要调试策略服务器,请执行以下操作:

    1. 通过以下命令检查服务器安装是否正确(Windows 上的 linux、mac 或 cygwin):echo -ne '&lt;policy-file-request/&gt;\0' | nc -v host port

    2. 通过在mm.cfg文件中设置标志PolicyFileLog=1打开flash播放器策略日志(确保你有flash播放器的debug version),运行swf文件并读取策略日志,它有用户友好的格式,您将能够在大多数情况下通过此日志找出问题。

    【讨论】:

    • 我能够设置一个从 cmd 控制台运行的 perl 独立服务器,但我的 flash 应用程序从未连接到它。我的 apache 服务器正在侦听的端口是否有问题?
    • 我用调试策略服务器的说明更新了我的答案
    • 我仍然遇到问题。我能够在我的服务器上设置策略服务器,并且在本地计算机上使用 netcat 能够访问服务器,但使用 perl 命令无法返回策略文件。使用 [perl -e 'printf "%c",0' | nc 127.0.0.1 843] 它在第 1 行 -e 处的 EOF 之前抛出错误 [Can't find string terminator "'"。当我 ^C out 时,我的策略服务器返回此 [Unrecognized Request]。当我尝试从本地机器以外的任何地方连接时,我无法连接。我需要更改 apache 服务器上的 hhtp.config 文件中的任何内容吗?
    • 您是否尝试过使用 echonc 的策略服务器检查命令变体?对策略服务器的请求必须完全等于 \0 ?将 PolicyFileLog 转为 1 也值得调试连接
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-27
    • 1970-01-01
    • 2021-08-12
    相关资源
    最近更新 更多