Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does the Flash Player throw a sandbox error in this case?
    text
    copied!<p>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.</p> <p>The sequence is as follows...</p> <p>1 Java server starts, listens on port 843 for policy file request and on port 45455 for my other requests.</p> <p>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.</p> <p>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.</p> <p>4 I serve the following XML from Java through port 843:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"&gt; &lt;cross-domain-policy&gt; &lt;site-control permitted-cross-domain-policies="all"/&gt; &lt;allow-access-from domain="*" to-ports="*" secure="false"/&gt; &lt;/cross-domain-policy&gt; </code></pre> <p>5 The player writes the following into the debug policy log...</p> <pre><code>OK: Root-level SWF loaded: http://localhost/bst/BasicSocketTest.swf OK: Searching for &lt;allow-access-from&gt; 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 </code></pre> <p>6 I send a text message from the client to the server on port 45455 using <code>writeUTFBytes()</code> and <code>flush()</code> (this is my own home-baked message protocol, and is correctly processed at each end)</p> <pre><code>REG/REGISTER;simon;Si </code></pre> <p>7 Java server thread listening on port 45455 responds with</p> <pre><code>REG:0/REGISTER:SUCCESS;simon;Si </code></pre> <p>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)</p> <p>9 The Flash player throws a 2048 sandbox error and the socket is disconnected! This is <em>after</em> the message is received and processed successfully. In fact it is about 12 seconds after. Nothing else works through the socket.</p> <p>I have tried explicitly loading a policy file with a call to <code>Security.loadPolicyFile()</code> 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 <em>always</em> goes to port 843 first looking for a master policy file. If it finds one, and it is permissive, it goes no further.</p> <p>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.</p> <p>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.</p> <p>Does anyone have any clue why this may be happening? Flash Player bug?</p> <p><strong>P.S.</strong> <em>Please</em> 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.</p> <p><strong>EDIT</strong> In response to James Ward's request in his comment, here is the entire error message:</p> <pre><code>Error #2048: Security sandbox violation: http://localhost/bst/BasicSocketTest.swf cannot load data from 192.168.2.3:45455. </code></pre> <p>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:</p> <pre><code>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. </code></pre> <p>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.</p> <p>I have <a href="http://bugs.adobe.com/jira/browse/FP-3302" rel="noreferrer">logged a bug at Adobe</a> about this.</p> <p>I can provide full source code of both client and server if anyone is interested.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload