Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 as3错误#2048:尝试通过套接字连接时发生安全沙盒冲突_Actionscript 3_Sockets_Flash_Crossdomain.xml - Fatal编程技术网

Actionscript 3 as3错误#2048:尝试通过套接字连接时发生安全沙盒冲突

Actionscript 3 as3错误#2048:尝试通过套接字连接时发生安全沙盒冲突,actionscript-3,sockets,flash,crossdomain.xml,Actionscript 3,Sockets,Flash,Crossdomain.xml,我在PHP web应用程序中嵌入了一个SWF文件。在我的系统上,所有本地和本地的。我想从我的SWF到localhost:4242(这是一个眼动跟踪api)建立一个套接字连接。当我使用flash player运行SWF时,一切都正常。但当我从浏览器运行它时,我得到: Security Error: [SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #204

我在PHP web应用程序中嵌入了一个SWF文件。在我的系统上,所有本地和本地的。我想从我的SWF到localhost:4242(这是一个眼动跟踪api)建立一个套接字连接。当我使用flash player运行SWF时,一切都正常。但当我从浏览器运行它时,我得到:

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."]
我将crossdomain.xml添加到本地web服务器()中,如下所示:

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

为了解决这个问题,我在网上查阅了所有资料。我不知道问题出在哪里,我该怎么办。

欢迎来到丛林!:)原因是您试图连接到不同的端口!这就是为什么您需要在那里为跨域服务。你用的是什么服务器?@AndreyPopov我用easyPhp(我在帖子中提到过)做我的网络应用,但是眼动仪。。。我不知道。眼球跟踪器(我想连接到它)是一个带有tcp api的设备。我通过端口4242连接到它。那么我应该怎么做呢?问题是你连接到不同的服务器(使用不同的端口)。此服务器需要使用正确的crossdomain.xml文件进行响应。通常它在端口843上运行,所以您可以尝试直接从那里加载它。请看这篇文章:这是一件棘手的事情,但通常人们会为crossdomain打开单独的端口,并为正确连接打开另一个端口(
4242
)@AndreyPopov-hum,我将本地服务器移到了端口843,然后尝试了“localhost:843/crossdomain.xml”和xmlsocket://localhost:843/crossdomain.xml". 仍然得到错误!我不明白“本地服务器”是什么意思。您的服务器是否可以在端口
843
上运行crossdomain.xml文件,同时允许在端口
4242
上进行套接字连接(指的是同一台服务器)?
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);