Results 1 to 12 of 12

Thread: XMLSocket, "Error #2048: Security sandbox violation"

  1. #1

    XMLSocket, "Error #2048: Security sandbox violation"

    I'm attempting to create an XMLSocket that connects to a PHP-written socket server.

    I think my code is pretty sound. I used to receive an IOError, but now that is solved and I keep receiving "Error #2048: Security sandbox violation". My .swf, socket server, and crossdomain files are all in the same directory.


    My ActionScript:

    Code:
    package
    {
        import flash.display.MovieClip;
        import flash.events.IOErrorEvent;
        import flash.events.Event;
        import flash.net.XMLSocket;
        import flash.text.*;
        import flash.events.ProgressEvent;
        import flash.events.SecurityErrorEvent;
        import flash.system.Security;
        
        public class XMLSocketTest extends MovieClip
        {
            public function XMLSocketTest():void
            {
                socket = new XMLSocket();
    
                socket.addEventListener(IOErrorEvent.IO_ERROR, traceError);
                socket.addEventListener(Event.CONNECT, connectionHandler);
                socket.addEventListener(ProgressEvent.PROGRESS, progressHandler);
                socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
            
                socket.connect("My IP Address", 9001);
            }
            
            private var socket:XMLSocket;
            
            private function progressHandler(event:ProgressEvent):void
            {
                tracer.text = String(event.bytesLoaded / event.bytesTotal);
            }
            
            private function securityErrorHandler(event:SecurityErrorEvent):void
            {
                tracer.text = event.text;
            }
            
            private function traceError(event:IOErrorEvent):void
            {
                tracer.text = event.text;
            }
            
            private function connectionHandler(event:Event):void
            {
                tracer.text = "Great success!";
            }
        }
    }
    The PHP Socket Server:
    Code:
    <?php
    // Set time limit to indefinite execution
    set_time_limit (0);
    
    // Set the ip and port we will listen on
    $address = 'My IP Address';
    $port = 9001;
    
    // Create a TCP Stream socket
    $sock = socket_create(AF_INET, SOCK_STREAM, 0);
    // Bind the socket to an address/port
    socket_bind($sock, $address, $port) or die('Could not bind to address');
    // Start listening for connections
    socket_listen($sock);
    
    /* Accept incoming requests and handle them as child processes */
    $client = socket_accept($sock);
    
    // Read the input from the client, up to 1024 bytes
    $input = socket_read($client, 1024);
    
    // Strip all white spaces from input
    $output = ereg_replace("[ \t\n\r]","",$input).chr(0);
    
    // Display output back to client
    socket_write($client, $output);
    
    // Close the client (child) socket
    socket_close($client);
    
    // Close the master sockets
    socket_close($sock);
    ?>
    The crossdomain policy file:
    Code:
    <?xml version="1.0"?> 
    <!-- http://10.0.1.31/crossdomain.xml --> 
    <cross-domain-policy> 
    <allow-access-from domain="*" to-ports="*" /> 
    </cross-domain-policy>
    Any help or advice would be much appreciated.
    Last edited by kedinik; May 16th, 2009 at 06:23 PM.

  2. #2
    Please, I would really appreciate it if someone could at least point me in the right direction.

  3. #3
    Hello,

    When you get "Error #2048: Security sandbox violation" you get the screen(see 1.jpg) then click on setting button then you

    get the screen(see 2.jpg) in your browser. then select the "add location" from drop down named "edit location" (see 3.jpg)

    one popup is displayed screen (see 4.jpg) put your localpath "c:\flash(just for an example)" in text box named "trust this

    location" (see 5.jpg) then click on confirm button (see 5.jpg) now you can see your localpath in the list of "always trust

    file in this location" list. (see 6.jpg).

    This is the solution of the "Security sandbox violation" error this error occur when you run file from local but when you run

    same file from live you haven't get an error "Security sandbox violation"

    if you have any query then get back to me.

    Regards,
    Kunjan

  4. #4

    this is first image for Security sandbox violation

    this is first image for Security sandbox violation
    Attached Files Attached Files
    • File Type: zip 1.zip (21.4 KB, 248 views)

  5. #5

    this is second image for Security sandbox violation

    this is second image for Security sandbox violation
    Attached Files Attached Files
    • File Type: zip 2.zip (122.3 KB, 163 views)

  6. #6

    this is third image for Security sandbox violation

    this is third image for Security sandbox violation
    Attached Files Attached Files
    • File Type: zip 3.zip (123.6 KB, 110 views)

  7. #7

    this is forth image for Security sandbox violation

    this is forth image for Security sandbox violation
    Attached Files Attached Files
    • File Type: zip 4.zip (124.0 KB, 104 views)

  8. #8

    this is fifth image for Security sandbox violation

    this is fifth image for Security sandbox violation
    Attached Files Attached Files
    • File Type: zip 5.zip (124.4 KB, 93 views)

  9. #9

    this is sixth image for Security sandbox violation

    this is sixth image for Security sandbox violation
    Attached Files Attached Files
    • File Type: zip 6.zip (122.0 KB, 102 views)

  10. #10
    Hello,

    I am attaching six images with .zip files because I am not able to attach all the files together..

    Regards,
    Kunjan

  11. #11
    Hi KUNJAN,

    Im looking for a solution for the Error #2048 from Flash. I have a server programm developed in Java usiong the class xSocket and it works fine. It manage the clients from Flash. Well, once i installed the server app in my domain "97.225.158.110" and running the client developed in Flash from my PC within Flash environment, it connects to the server with no problem. But, if i upload the flash to the domain and invoke it from the web, it doesnt work. Well, i have been seeing many web pages mentioning the policy file and i will show you how i have done it:

    In the the Java App i have a event handler for incomming data where i idetify the incomming string:

    Code:
    if(data.equalsIgnoreCase("<policy-file-request/>")) {
                    	Main.Log.append("Enviando archivo Politica Seguridad");
                        nbc.write("<cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"8090\"/></cross-domain-policy>\0");
                        return true;
                    }
    In the Flash App i have the following code:

    Code:
    // Conexion con el Servidor BM.
    			xmlSocket = new XMLSocket();
    			//variablesAG.error.text = "COnectando";
    			xmlSocket.connect("97.225.158.110", 8090);
    			
    			// Petición de Seguridad de Flash.
    			try {
    				Security.loadPolicyFile("xmlsocket://97.225.158.110:8090");
    			} catch (e:IOError) {
    				variablesAG.error.text = "Securidad:"+e.text;
    			}
    Well, the java server app receive the string policy request and it should answer with the quoted file but the Flash never receive it and in a minute the Error 2048 appear. Whats wrong?

    I would appreciate your help.

    Thanks in advance.

  12. #12
    @kedinik
    did you ever get that to work?
    I'm having the same problem... well, sort of.
    When I run my flash project as an application it connects to the server without a problem, but if I run it in a webpage (same domain, same folder, same everything as the server) the connection fails.
    Did anybody ever got this to work?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012