jeudi 28 mai 2015

as3 Error #2048: Security sandbox violation when trying to connect through socket

I have a SWF file embedded in a PHP web application. All local and on my system. I want to make a socket connection from my SWF to localhost:4242 (which is an eye tracker api). When I run SWF using flash player everything works fine. But when I run it from browser I get:

Security Error: [SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048: Security sandbox violation: http://localhost/graph/assets/swf/Graph.swf cannot load data from http://localhost:4242."]

I added crossdomain.xml to my local web server (easy php) like this:

<?xml version="1.0" ?>
  <cross-domain-policy>
  <site-control permitted-cross-domain-policies="master-only"/>
  <allow-access-from domain="*" to-ports="*" secure="false"/>
  <allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

and this is my action script for socket connection:

socket = new Socket();
Security.allowDomain("*");
Security.allowInsecureDomain("*");
Security.loadPolicyFile("http://localhost/crossdomain.xml");
socket.addEventListener(Event.CONNECT, onSocketConnect);
socket.addEventListener(Event.CLOSE, onClose);
socket.addEventListener(IOErrorEvent.IO_ERROR, onError);
socket.addEventListener(ProgressEvent.SOCKET_DATA, onResponse);
socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecError);

socket.connect("http://localhost", 4242);

I went through everything on web for solving this problem. I don't know what the problem is and what should I do.

Aucun commentaire:

Enregistrer un commentaire