简体   繁体   中英

AS3 + PHP Socket Server Connection Issues

My question is related to the one asked here - Flash socket server only works on local machine

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. I think my problem is related to the crossdomain file, but I can't find much information on it.

Here is my code.

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;

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.

UPD: To debug the policy server do the following:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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