title: Flex: Error #2048 when connecting to a WebSocket
body: <p>I've implemented a simple Flex application that tries to connect to a server via the WebSocket protocol. Running the app in the Flash Builder 4.6 debugger everything works fine. So I installed the application on my server and now I get Error #2048 after a while. #2048 seems to be an error concerning security.</p>
  
  <p>The server provides this crossdomain.xml:</p>
  
  <p><strong>Updated</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
    &lt;cross-domain-policy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFileSocket.xsd"&gt;
    &lt;allow-access-from domain="*" to-ports="*"  /&gt;
    &lt;site-control permitted-cross-domain-policies="master-only" /&gt;
  &lt;/cross-domain-policy&gt;
  </code></pre>
  
  <p><strong>Edit:</strong> It's provided by calling</p>
  
  <pre><code>Security.loadPolicyFile('http://myserver:8081/crossdomain.xml');
  </code></pre>
  
  <p>I can see in the web server logs that the client loads it.</p>
  
  <p>I'm using <a href="https://github.com/Worlize/AS3WebSocket" rel="nofollow">AS3WebSocket</a> as the WebSocket implementation for Flex.</p>
  
  <p>This is how I set up the WebSocket object:</p>
  
  <pre><code>websocket = new WebSocket(url, "*", 'dummy', 5000);
  // adding several event handler ...
  websocket.connect();
  </code></pre>
  
  <p>The browser connects to the server with</p>
  
  <pre><code>http://myserver:8081
  </code></pre>
  
  <p>The <em>url</em> parameter holds</p>
  
  <pre><code>ws://myserver:8081/data
  </code></pre>
  
  <p>Why does it work locally with the Flash Builder and not on my server? What am I missing?</p>