9 Replies Latest reply on Jul 29, 2009 7:08 AM by Iteryx

    Error #2044 & Error #2048




      I am running Flex 4 SDK and a beta of Flash Builder 4 on an Eclipse IDE. I have two files: one is a small flex program that establishes a XML Socket on the localhost, the other is a Java program that writes a simple string to the port that the flex program listens to. The purpose of this program is to get used to TCP with flex. Both programs run inside of the Eclipse IDE. However, when I run the program, I get the following error message:


      Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation


      I have searched quite a bit for a solution to this problem to no avail.  Any help would be greatly appreciated.


      Thank you.

        • 1. Re: Error #2044 & Error #2048
          Flex harUI Adobe Employee

          There are "Security WhitePapers" on the Adobe site.  They explain the rules for security.


          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          1 person found this helpful
          • 2. Re: Error #2044 & Error #2048
            Iteryx Level 1

            Thank you Alex for your reply.


            I have checked into the security whitepapers I could find, and they did have some thoughts that I had not tried. However, its still not working. I have put crossdomain policy files in the bin directories of both programs in Eclipse that I am trying to make talk to each other. I have set my compiler option -use-network=false because they are on the same local machine. I will state again that both programs are running from the same Eclipse IDE window ( I start one, then start the other ). I am trying to use an XMLSocket for the Flex side of things and the other is a simple Java program that puts a string in the socket the XMLSocket is bound to.



            1. Do you Alex, or anyone else, have a specific list of security whitepapers (or other resources) I should look at?
            2. Does anyone know if there is a setting in Eclipse to point to the cross-domain policy file for Flash Builder 4?
            3. Is the XMLSocket class capable of doing this type of connection in the first place? Should I just use Socket?


            Again, any assistance would be most appreciated.

            • 3. Re: Error #2044 & Error #2048
              CoreyRLucier Adobe Employee

              For what it's worth, I just put together something simple and it seems to work:


              Both are run from a common folder.  Note that (AFAIK) you can't create a socket server in Flash (only clients)...so the java socket server needs to be started first:


              Keep in mind that things won't work out of the box (due to security issues) - an easy way to get things up and running (sans crossdomain file returned from your socket server) is to ensure your app is running in the local-trusted sandbox.


              To do this you need to add the path (where your Client.swf resides) to a text file living in either your global "FlashPlayerTrust" folder or your user level FlashPlayerTrust folder.


              For example, on Mac I've added a file called 'trust' containing one line:




              ... to my "global" FlashPlayerTrust folder located at: /Library/Application Support/Macromedia/FlashPlayerTrust.


              See http://livedocs.adobe.com/flex/3/html/help.html?content=security2_25.html


              Pardon the verbose post, attachments don't work too well for me lately so included src inline...





              import java.io.*;
              import java.net.*;


              public class SimpleServer
                      public static void main(String args[])
                              // Message terminator
                              char EOF = (char)0x00;


                                      // create a serverSocket connection on port 9999
                                      ServerSocket s = new ServerSocket(9999);


                                      System.out.println("Server started. Waiting for connections...");
                                      // wait for incoming connections
                                      Socket incoming = s.accept();


                                      BufferedReader data_in = new BufferedReader(
                                            new InputStreamReader(incoming.getInputStream()));
                                      PrintWriter data_out = new PrintWriter(incoming.getOutputStream());


                                      data_out.println("Welcome! type EXIT to quit." + EOF);


                                      boolean quit = false;


                                      // Waits for the EXIT command
                                      while (!quit)
                                              String msg = data_in.readLine();


                                              if (msg == null) quit = true;


                                              if (!msg.trim().equals("EXIT"))
                                                      data_out.println("You sayed: <b>"+msg.trim()+"</b>"+EOF);
                                                      quit = true;
                              catch (Exception e)
                                      System.out.println("Connection lost");


              Client.mxml (Flex 4):


              <?xml version="1.0" encoding="utf-8"?>
              <Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                           width="1024" height="768">


                  <!-- Compiled FXG placed on the left -->
                          import flash.net.XMLSocket;
                          import flash.events.*;


                          private var hostName:String = "localhost";
                          private var port:uint = 9999;
                          private var socket:XMLSocket;


                          public function connect():void {
                              socket = new XMLSocket();
                              socket.connect(hostName, port);


                          public function send(data:Object):void {


                          private function configureListeners(dispatcher:IEventDispatcher):void {
                              dispatcher.addEventListener(Event.CLOSE, closeHandler);
                              dispatcher.addEventListener(Event.CONNECT, connectHandler);
                              dispatcher.addEventListener(DataEvent.DATA, dataHandler);
                              dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
                              dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
                              dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);


                          private function closeHandler(event:Event):void {
                              ta.text += String("closeHandler: " + event);


                          private function connectHandler(event:Event):void {
                              ta.text += String("connectHandler: " + event);


                          private function dataHandler(event:DataEvent):void {
                              ta.text += String("dataHandler: " + event);


                          private function ioErrorHandler(event:IOErrorEvent):void {
                              ta.text += String("ioErrorHandler: " + event);


                          private function progressHandler(event:ProgressEvent):void {
                              ta.text += String("progressHandler loaded:" +

                                          event.bytesLoaded + " total: " + event.bytesTotal);


                          private function securityErrorHandler(event:SecurityErrorEvent):void {
                              ta.text += String("securityErrorHandler: " + event);


                  <Button label="connect" click="connect()"/>
                  <TextArea id="ta" width="300" height="200"/>



              • 4. Re: Error #2044 & Error #2048
                CoreyRLucier Adobe Employee

                This post was also helpful and worked for me... shows how you can easily setup your socket server to also serve up the cross domain policy file.




                Note the call to System.security.loadPolicyFile prior to making the client connection.





                • 5. Re: Error #2044 & Error #2048
                  Iteryx Level 1

                  Corey, thank you for your replies.


                  I tried doing what you suggested with creating a text file with the path to my .swf location. In Vista, the FlashPlayerTrust file is not where it should be inside of C:/Windows/System32/Macrmed/Flash. I created a FlashPlayerTrust file and put a text document in it. It didn't work. I also dug around a bit on the internet and tried editing my global security settings by right clicking on my flash application inside of my web browser and that didn't work either. I also looked at your code samples and they look about the same as to what I am trying to do, so it was good to see you solved the same problem I have. Unfortunately, I cannot get it to work at all. Its the same error every time.


                  I have looked at your link to the blog.pettomato.com and I'm still trying to figure out how to do that inside of Java. Little rusty on ServerSockets. However, inside of the actionscript, the "System.security.loadPolicyFile" method gave me a compiler error, so I couldn't use it or I am using it wrong.



                  1. The compiler does let me use "Security.loadPolicyFile" method, would that do the same thing as the "System.security.loadPolicyFile" ?
                  2. Do you, or anyone else, know about any settings I need to do in Eclipse to make this work?


                  Any help would be appreciated. Thanks.

                  • 6. Re: Error #2044 & Error #2048
                    CoreyRLucier Adobe Employee
                    import flash.system.Security;
                    Security.loadPolicyFile(...) should work fine.

                    Sorry to hear you are on Vista..will try to dig up where the global FlashPlayerTrust folder is.


                    • 7. Re: Error #2044 & Error #2048
                      Iteryx Level 1

                      Thank you Corey. Your help is very appreciated. I will continue to try and find a solution to this problem as well.

                      • 8. Re: Error #2044 & Error #2048
                        CoreyRLucier Adobe Employee

                        This may help:  http://opensource.adobe.com/wiki/display/flexsdk/Setup+on+Windows


                        Scroll down to the FlashPlayerTrust section, they mention a Vista specific issue with creation of the folder and file...  perhaps thats what you ran into.


                        In any event, the trust file they setup in those steps is all inclusive (of C:\)..curious if that liberal policy helps your case.



                        • 9. Re: Error #2044 & Error #2048
                          Iteryx Level 1

                          Little update, our company has purchased Flex 3 licenses, so that is what I am working with now. However, the same problem still exists there as well. It all has to do with the security sandbox, crossdomain.xml, and other security issues. I have posted a new post over in the Flex 3 forums, to little avail. Going to be updating it with what I have been doing to try and figure out this stuff.


                          Link to the Flex 3 forum post:



                          I will be reviewing that prior post as well, Corey. Thank you.


                          EDIT: Just finsihed trying out the Configure Flash Player section in the link from you last post, Corey. It didn't work either, but thanks for the suggestion anyway.