简体   繁体   English

AS3 + PHP套接字服务器连接问题

[英]AS3 + PHP Socket Server Connection Issues

My question is related to the one asked here - Flash socket server only works on local machine 我的问题与此处提出的问题有关-Flash套接字服务器仅在本地计算机上有效

My flash application works fine running on a local apache server on my local machine but when I try and connect to a PHP socket server running on my Amazon server it fails to connect. 我的Flash应用程序可以在本地计算机上的本地apache服务器上正常运行,但是当我尝试连接到在Amazon服务器上运行的PHP套接字服务器时,它无法连接。 I think my problem is related to the crossdomain file, but I can't find much information on it. 我认为我的问题与跨域文件有关,但是我找不到关于它的太多信息。

Here is my code. 这是我的代码。

AS3: 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: PHP:

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

Crossdomain: 跨网域:

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

Let me know if I need to add any further information. 让我知道是否需要添加其他信息。

Thanks 谢谢

Check out this my answer Annoying Error #2048: Security sandbox violation from localhost , you need to setup socket policy server on 843 port or on your connection port (9999), rather then http delivered xml. 签出我的答案烦人的错误#2048:来自localhost的安全沙箱冲突 ,您需要在843端口或连接端口(9999)上设置套接字策略服务器,而不是http提供的xml。

UPD: To debug the policy server do the following: UPD:要调试策略服务器,请执行以下操作:

  1. Check that server installing is correct by the command (linux, mac or cygwin on Windows): echo -ne '<policy-file-request/>\\0' | nc -v host port 通过以下命令(在Windows上为linux,mac或cygwin)检查服务器安装是否正确: echo -ne '<policy-file-request/>\\0' | nc -v host port echo -ne '<policy-file-request/>\\0' | nc -v host port

  2. Turn on the flash player policy log by setting the flag PolicyFileLog=1 in mm.cfg file (be sure you have the debug version of flash player), run swf file and read the policy log, it has user friendly format, you will be able to figure out the problem in most cases by this log. 通过在mm.cfg文件中设置标志PolicyFileLog=1来打开Flash Player策略日志(确保您具有Flash Player的调试版本 ),运行swf文件并读取策略日志,它具有用户友好的格式,您将能够在大多数情况下通过此日志解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM