安全沙箱违规,无法通过 Socket 连接到服务器 [英] Security Sandbox Violation, can't connect to Server via Socket

查看:33
本文介绍了安全沙箱违规,无法通过 Socket 连接到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我开始之前,我应该声明我已经阅读了所有内容,我正在关注 这个这个this(以及更多...)但我仍然无法通过 Socket over 连接到我们正在运行的服务器互联网.

Before I start I should state I have read it all, I was following this, this and this (and more...) and still I cannot connect to our running server via Socket over the internet.

这是我在 AS3 中的尝试:

Here is what I try to in AS3:

        var host :String = "192.168.2.11";
        Security.allowDomain(host);
        Security.allowInsecureDomain(host);
        Security.loadPolicyFile("xmlsocket://" + host + ":" +  "843");

        // TTS server socket
        _socket = new Socket();
        _socket.addEventListener(Event.CLOSE, handleClose);
        _socket.addEventListener(IOErrorEvent.IO_ERROR, handleError);
        _socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, handleSecError);
        _socket.addEventListener(ProgressEvent.SOCKET_DATA, handleIncomingData);
        _socket.addEventListener(Event.CONNECT, handleConnect);
        _socket.connect(host, 1337);

如您所见,主机是本地地址,但只要我在此本地网络中,这应该无关紧要.我是,因为这在我的 IDE (FD4) 中确实有效.此外,swf 与其尝试连接的应用程序位于同一服务器上,但位于另一个端口上.

As you can see, the host is a local address, but that shouldn't matter as long as I am in this local network. And I am, since this does work from my IDE (FD4). Also, the swf is on the same server as the application it tries to connect to, but on another port.

服务器发送的策略文件(我们从 843 和 1337 端口都尝试过)如下:

The policy file the server sends (we have tried both from port 843 and 1337) is the following:

<?xml version="1.0"?> 
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> 
<cross-domain-policy> 
    <allow-access-from domain="*" to-ports="*" /> 
</cross-domain-policy>

我们从服务器的日志输出中可以看出,这是真正发送到连接套接字的.在 xml 数据之后当然会发送一个空字节.之后,服务器关闭连接.但是,Flash 似乎不喜欢它,因为大约 3 秒后仍然出现错误 #2048".

We can see from the log output of the server that this is really sent to the connecting socket. A null byte is of course sent after the xml data. And after that, the server closes the connection. However, it seems that Flash somehow does not like it, as "Error #2048" still appears after ~3 seconds.

我们真的没有想法...

We're really out of ideas here...

推荐答案

我们设法通过包含另一个标签使其工作:

We managed to get it to work by including another tag:

<site-control permitted-cross-domain-policies="master-only"/>

这个标签似乎是让它工作所必需的.无论我们尝试哪个端口,如果没有那个标签,我们都无法让它工作.

It seems that this tag is necessary in order to get it to work. We could not get it to work without that tag, no matter which port we tried.

所以在我们的例子中,完整的 xml 现在看起来像这样(当然可以很容易地修改以适应任何情况):

So the complete xml now looks like this in our case (it is of course easy to modify to fit any case):

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
   <site-control permitted-cross-domain-policies="master-only"/>
   <allow-access-from domain="*" to-ports="*"/>
</cross-domain-policy>

很遗憾,Adobe 自己的示例(!!).我的意思是,它包含在示例文件中,但不在文章中.我不想知道有多少人因为那个被困在这个阶段......

It really is a shame that this line is not included in Adobe's own example (!!). I mean, it IS included in the example files, but not in the article. I don't want to know how many people were stuck at this stage because of that...

这篇关于安全沙箱违规,无法通过 Socket 连接到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆