为什么 Flash Player 在这种情况下会抛出沙箱错误? [英] Why does the Flash Player throw a sandbox error in this case?

查看:70
本文介绍了为什么 Flash Player 在这种情况下会抛出沙箱错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在连接到 Java (1.5) 服务器上的套接字后,我收到 Flex 3 沙箱错误 #2048.服务器代码都是我的,即不在 Apache 下运行.Flash Player 10.0 r32.

I get a Flex 3 sandbox error #2048 after connecting to a Socket on a Java (1.5) server. The server code is all mine, i.e. not running under Apache. Flash Player 10.0 r32.

顺序如下...

1 个 Java 服务器启动,在端口 843 上侦听策略文件请求,在端口 45455 上侦听我的其他请求.

1 Java server starts, listens on port 843 for policy file request and on port 45455 for my other requests.

由 Apache 提供服务的 2 个 Flex 客户端(尽管如果我从文件系统运行它,我会得到相同的结果),在主机:45455 上建立的套接字连接.

2 Flex client served by Apache (although I get the same result if I run it from the file system), socket connection made on host:45455.

3 Flash Player 从端口 843 请求策略文件.这是寻找主文件的新安全设置的标准行为.无论是否指定了不同的策略文件,都会发生这种情况.

3 Flash Player requests policy file from port 843. This is the standard behaviour with the new security settings looking for a master file. It happens regardless of whether a different policy file has been specified.

4 我通过端口 843 从 Java 提供以下 XML:

4 I serve the following XML from Java through port 843:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
</cross-domain-policy>

5 玩家将以下内容写入调试策略日志...

5 The player writes the following into the debug policy log...

OK: Root-level SWF loaded: http://localhost/bst/BasicSocketTest.swf
OK: Searching for <allow-access-from> in policy files to authorize data loading from resource at xmlsocket://192.168.2.3:45455 by requestor from http://localhost/bst/BasicSocketTest.swf
OK: Policy file accepted: xmlsocket://192.168.2.3:843
OK: Request for resource at xmlsocket://192.168.2.3:45455 by requestor from http://localhost/bst/BasicSocketTest.swf is permitted due to policy file at xmlsocket://192.168.2.3:843

6 我使用 writeUTFBytes()flush()(这是我自己的自制消息协议)在端口 45455 上将文本消息从客户端发送到服务器, 并在每一端正确处理)

6 I send a text message from the client to the server on port 45455 using writeUTFBytes() and flush() (this is my own home-baked message protocol, and is correctly processed at each end)

REG/REGISTER;simon;Si

7 Java 服务器线程监听端口 45455 响应

7 Java server thread listening on port 45455 responds with

REG:0/REGISTER:SUCCESS;simon;Si

8 Flex 客户端收到一个 ProgressEvent 并且我绑定到套接字的事件侦听器被调用.我处理消息(将其写入屏幕上的文本框)

8 The Flex client receives a ProgressEvent and the event listener I bound to the socket gets called. I process the message (write it to a text box on the screen)

9 Flash 播放器抛出 2048 沙箱错误,socket 断开!这是之后消息被成功接收和处理.实际上是大约 12 秒后.没有其他东西通过套接字工作.

9 The Flash player throws a 2048 sandbox error and the socket is disconnected! This is after the message is received and processed successfully. In fact it is about 12 seconds after. Nothing else works through the socket.

我曾尝试在 Flex 客户端中通过调用 Security.loadPolicyFile() 显式加载策略文件,但新播放器安全性的现实是它基本上被忽略了.步骤是直到发生套接字 i/o 操作时才会发送策略请求.在这一点上,玩家总是首先去端口 843 寻找主策略文件.如果它找到了一个,并且是允许的,它就不会再进一步​​了.

I have tried explicitly loading a policy file with a call to Security.loadPolicyFile() in the Flex client, but the reality of the new player security is that it is basically ignored. The steps are that the policy request will not get sent until a socket i/o operation occurs. At that point the player always goes to port 843 first looking for a master policy file. If it finds one, and it is permissive, it goes no further.

我尝试了多种终止策略文件和策略文件内容的替代方法,包括故意错误以查看 Flash Player 是否处于唤醒状态.

I have tried a variety of alternative ways of terminating the policy file and policy file contents, including deliberate errors just to see if the Flash Player is awake.

我看不出有什么理由会抛出 2048.我在指定的主安全端口上准确地提供了一个套接字策略文件,播放器本身将其记录为正确的.然后套接字成功地从服务器发送和接收消息,其中的内容可供我的代码使用.

I can see no reason why I would have a 2048 being thrown. I accurately serve a socket policy file on the designated master security port, which the player itself logs as correct. The socket then successfully sends and receives a message from the server the contents of which are available to my code.

有人知道为什么会发生这种情况吗?Flash Player 错误?

Does anyone have any clue why this may be happening? Flash Player bug?

PS 不要告诉我使用 BlazeDS 或 LCDS 或 Granite 或其他东西作为服务器,我正在寻找解决此问题的方法,不是重新设计.并且请不要让我改用 XMLSocket - 我试过了,得到了完全相同的结果.我精心选择了我的架构,我想要一个二进制套接字.

P.S. Please don't tell me to use BlazeDS or LCDS or Granite, or something else as a server, I'm looking for a solution to this problem, not a redesign. And please don't ask me to use an XMLSocket instead - I tried that and get exactly the same result. I have chosen my architecture carefully and deliberately and I want a binary socket.

编辑为了回应 James Ward 在他的评论中的要求,这里是完整的错误信息:

EDIT In response to James Ward's request in his comment, here is the entire error message:

Error #2048: Security sandbox violation: http://localhost/bst/BasicSocketTest.swf cannot load data from 192.168.2.3:45455.

我有一个精简的测试客户端,它为每个套接字事件提供一个处理程序,并向屏幕输出一条消息.这是它显示的内容:

I have a stripped down test client which has a handler for each socket event and outputs a message to the screen. This is what it shows:

RequestPolicy: 192.168.2.3:843
Create Socket: 192.168.2.3:45455
Connect: [Event type="connect" bubbles=false cancelable=false eventPhase=2]
Sending: REG/REGISTER;simon.palmer@gmail.com;Si
Receiving: REG:0/REGISTER:SUCCESS;simon.palmer@gmail.com;Si/
Close: [Event type="close" bubbles=false cancelable=false eventPhase=2]
Error #2048: Security sandbox violation: http://localhost/bst/BasicSocketTest.swf cannot load data from 192.168.2.3:45455.

关闭事件在成功接收到服务器响应后立即触发,但是错误 #2048 直到大约 20 秒后才会出现.如果我在关闭之后尝试发送进一步的消息,但在错误之前,Flash Player 会抛出一个无效的套接字异常.

The close event is fired immediately after successfully receiving a response from the server, however the Error #2048 does not appear until about 20 seconds later. If I try and send a further message after close, but before the error, the Flash Player throws an invalid socket exception.

在 Adob​​e 记录了一个错误.

如果有人感兴趣,我可以提供客户端和服务器的完整源代码.

I can provide full source code of both client and server if anyone is interested.

推荐答案

我一直在本地对此进行测试,在套接字关闭之前,一切似乎都运行良好.套接字不应该关闭吗?消息发送到 Flex 客户端后,Java 代码执行以下操作:

I've been testing this locally and everything seems to be working fine until the socket gets closed. Shouldn't the socket not get closed? After the message is sent to the Flex client, the Java code does:

_in.close();
_out.close();
_socket.close();

然后 Flex 客户端在下次尝试与套接字通信时遇到沙箱冲突.如果我再次创建一个新的套接字连接,则发送和接收工作正常,然后关闭.但是大约一分钟后,我又遇到了沙箱违规.我想知道 Flash 是否正在尝试 ping 套接字,并且由于它已关闭,因此会引发沙箱违规?

Then the Flex client gets the sandbox violation the next time it tries to communicate with the socket. If I create a new socket connection again then send and receive works fine, followed by a close. But after a minute or so I get another sandbox violation. I wonder if Flash is trying to ping the socket and since it's closed it throws the sandbox violation?

这篇关于为什么 Flash Player 在这种情况下会抛出沙箱错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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