Skip navigation
Currently Being Moderated

Error #2044 & Error #2048

Jul 7, 2009 11:46 AM



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.

  • Currently Being Moderated
    Jul 7, 2009 1:31 PM   in reply to Iteryx

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


    Alex Harui

    Flex SDK Developer

    Adobe Systems Inc.


    Mark as:
  • Currently Being Moderated
    Jul 8, 2009 8:32 AM   in reply to Iteryx

    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) 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 tml


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






    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=""
                 width="1024" height="768">


        <!-- Compiled FXG placed on the left -->


                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"/>



    Mark as:
  • Currently Being Moderated
    Jul 8, 2009 8:48 AM   in reply to CoreyRLucier

    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 prior to making the client connection.





    Mark as:
  • Currently Being Moderated
    Jul 8, 2009 11:46 AM   in reply to Iteryx
    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.


    Mark as:
  • Currently Being Moderated
    Jul 9, 2009 10:51 AM   in reply to Iteryx

    This may help:


    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.



    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points