[SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048: Security Sandbox Violation : http://127.0.0.1/jssockets/JsSocket.swf can not load data from

Hi,

I want to run a JsSocket on my local machine (localhost), i donwload JsSocket from http://code.google.com/p/jssockets/ , i create a sub-folder 'jssockets' under easyphp's 'www' folder, where i unzip the JsSocket package. after i edit the JSSocket.mxml by adding this lines to "connect" function :


Security.allowDomain("*");
Security.loadPolicyFile("http://127.0.0.1/jssockets/crossdomain.xml");



i builder JsSocket.mxml by FLex builder 3,  after i replace the original JsSockety.swf by the JsSockety.swf spring from the flex builder. on easy php i add alias "http://127.0.0.1/jssockets/" to my jssockets's folder and i create a crossdomain.xml to allow all domain acces



<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"> 
<cross-domain-policy>
  <allow-access-from domain="*"  to-ports="*" />
  <allow-http-request-headers-from domain="*" headers="*" />
</cross-domain-policy>


i run my Java Server on the port 10000 and i run on the ie 8 browser the index.html from adresse http://127.0.0.1/jssockets/ and i try to connect my JsSocket to the host http://127.0.0.1/jssockets/ on the port 10000 but evry what i do i have always this error



[SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048: Security Sandbox Violation : http://127.0.0.1/jssockets/JsSocket.swf can not load data from http://127.0.0.1/jssockets/:10000."]

All help are welcome


The JsSocket.mxml are writen under actionscript 3
The flash version on my machine is 10
i use flex builder 3 to compile JsSocket.mxml
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    creationComplete="init();">

    <mx:Script><![CDATA[

        import flash.system.Security;
        import flash.external.ExternalInterface;
        import remoting.*;

        private var _socket:RemotingSocket;

        private var connect_cb:String       = null;
        private var disconnect_cb:String    = null;
        private var recieve_cb:String       = null;
        private var ioerror_cb:String       = null;
        private var securityerror_cb:String = null;
        private var progressevent_cb:String = null;
            
        private function connect(server:String,port:int):void
        {
            try
            {
                dbg("Flash Connecting to "+server+":"+port.toString());
    
                _socket = new RemotingSocket(server,port);
                _socket.addEventListener("newRemotingMsg",remotingSocketHandler);
            
                _socket.addEventListener(Event.CONNECT, function(e:Event):void
                {
                    handleEvent(e,connect_cb);
                });
    
                _socket.addEventListener(Event.CLOSE, function(e:Event):void
                { 
                    handleEvent(e,disconnect_cb);
                });
    
                _socket.addEventListener(IOErrorEvent.IO_ERROR, function(e:Event):void
                { 
                    handleEvent(e,ioerror_cb);
                });
    
                _socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function(e:Event):void
                { 
                    handleEvent(e,securityerror_cb);
                });
    
                _socket.addEventListener(ProgressEvent.SOCKET_DATA, function(e:Event):void
                { 
                    handleEvent(e,progressevent_cb);
                });
            }
            catch (err:IOErrorEvent)
            {
                dbg("Flash Error: "+err.toString());
            }
        }

        private function handleEvent(event:Event,callback:String):void
        {
            dbg(event.toString());

            if(callback != null)
                ExternalInterface.call(callback);
        }

        private function remotingSocketHandler(event:RemotingEvent):void
        {
            dbg("Flash Recieved : " + event.toString());

            if(recieve_cb != null)
                ExternalInterface.call(recieve_cb,event.message);
        }

        private function write(str:String):void
        {
            dbg("Flash Writing : " + str);
            _socket.write(str);
        }

        private function disconnect():void
        {
            dbg("Flash Closing Socket");
            _socket.close();

            // Shouldnt flash call this?
            if(!_socket.connected)
                handleEvent(new Event("Fake Disconnect Event"),disconnect_cb);
        }

        private function setCallBack(str:String,fun:String):void
        {

            dbg("Flash Set Callback for " + str + " to " + fun);

            switch (str) 
            {
                case "connect" :       connect_cb = fun;        break;
                case "disconnect" :    disconnect_cb = fun;     break;
                case "recieve" :       recieve_cb = fun;        break;
                case "ioerror" :       ioerror_cb = fun;        break;
                case "securityerror" : securityerror_cb = fun;  break;
                case "progressevent" : progressevent_cb = fun;  break;
            }
        }

        private function init():void
        {
            dbg("Flash initialised, calling jssocket_init");
    
            try
            {
                ExternalInterface.addCallback("setCallBack",setCallBack);
                ExternalInterface.addCallback("connect",connect);
                ExternalInterface.addCallback("write",write);
                ExternalInterface.addCallback("disconnect",disconnect);
                ExternalInterface.call("jssocket_init");
            }
            catch (err:Error)
            {
                dbg("Flash Error: "+err.toString());
            }
        }

        private function dbg(msg:String):void
        {
            debug.text += msg + "\n";
        }

    ]]></mx:Script>

    <mx:TextArea id="debug" width="100%" height="100%" />

</mx:Application>

Open in new window

enferAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DeasilCommented:
Hi there,
I think it may be to do with the fact that as of FP 9, you have to serve your policy file explicity from the same socket you'll be connecting to.  Security gets tighter and tighter - not surprising, but it does create more work every time
!
So - I've not actually done this, and it's dependent on your setup, but I would try something like:

Security.loadPolicyFile("xmlsocket://127.0.0.1:10000");

And in the XML file you have to specifically include the port number, you can't use the * any more.

You can find out more about this from Adobe at
http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html

As I say, not an expert in sockets, but that's what it looks like to me.

Hope this helps.

D
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DeasilCommented:
PS - sorry, forgot to note that you can't serve the policy via HTTP for the socket connection!
0
enferAuthor Commented:
Hi, Deasil

i try what you asking me to do , and i look the loggin policy file (policyfile.txt) and i note that the socket can't found the crossdomain.xml. to be sure that this file exist i place this file in this folders:

C:\Program Files\EasyPHP 2.0b1\www    (http://127.0.0.1/)   And C:\Program Files\EasyPHP 2.0b1\www\jssockets  (http://127.0.0.1/jssockets)  

but alway i have the same error (crossdomain.xml not valid synthax that mean that this file not exist).

i try to send a crossdomain file from the java server. the server connect to the flash client but when the server send the crossdomain and the server stop for an unknown reasons and the flash return the same error as above.

then what is the best configuration to run flash socket using easyphp and what is the best implementation of the java server?

tkx..
import java.io.*; 
import java.net.*; 
 
class SimpleServer  
{ 
    private static SimpleServer server; 
    ServerSocket socket; 
    Socket incoming; 
    BufferedReader readerIn; 
    PrintStream printOut; 
 
    public static void main(String[] args) 
    { 
        int port = 10000; 
 
        try 
        { 
            port = Integer.parseInt(args[0]); 
        } 
        catch (ArrayIndexOutOfBoundsException e) 
        { 
            // Catch exception and keep going. 
        } 
 
        server = new SimpleServer(port); 
    } 
 
    private SimpleServer(int port) 
    { 
        System.out.println(">> Starting SimpleServer"); 
        try 
        { 
            socket = new ServerSocket(port); 
            incoming = socket.accept(); 
            readerIn = new BufferedReader(new InputStreamReader(incoming.getInputStream())); 
            printOut = new PrintStream(incoming.getOutputStream()); 
            printOut.println("Enter EXIT to exit.\r"); 
       //     out("Enter EXIT to exit.\r"); 
            boolean done = false; 
            while (!done) 
            { 
                String str = readerIn.readLine(); 
                if (str == null) 
                { 
                    done = true; 
                } 
                else 
                { 
                  //  out("Echo: " + str); 
                    if((str.trim().equals("<policy-file-request/>")) || str.trim().equals("<allow-access-from>")) 
                    { 
	//out("<?xml version=\"1.0\"?><!DOCTYPE cross-domain-policy SYSTEM \"/xml/dtds/cross-domain-policy.dtd\"><!-- Policy file for xmlsocket://socks.example.com --><cross-domain-policy><!-- This is a master-policy file --><site-control permitted-cross-domain-policies=\"master-only\"/><!-- Instead of setting to-ports=\"*\",administrators can use ranges and commas --><!-- This will allow access to ports 123, 456, 457, and 458 --><allow-access-from domain=\"localhost\" to-ports=\"10000\" /></cross-domain-policy>");
    
       out("<cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"10000\" /></cross-domain-policy>\\x00");           	
                    	
                    	
                    	// done = true; 
                    } 
                    
                } 
                incoming.close(); 
            } 
        } 
        catch (Exception e) 
        { 
            System.out.println(e); 
        } 
    } 
 
    private void out(String str) 
    { 
        printOut.println(str); 
        System.out.println(str); 
    } 
}

Open in new window

0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

enferAuthor Commented:
Hi,

it work finaly,

i devellope a little java server to send the crossdomain.xml on the principal connection port and disconect and reconnecte with the same client (flash connecte with 843 or the principal port to read xml crossdomain and deconnet to reconnect to do wath you need with this little socket)

flash 10 it 's importante to send crossdomain with the server connection to the flash client although you have a crossdomain file placed at the root server

0
enferAuthor Commented:
for any other helps : fashiondragon@hotmail.fr
0
enferAuthor Commented:
adios
0
DeasilCommented:
Hey enfer!  Sounds like you had a busy night!  I guess I was part right - but these security issues are causing a lot of problems for people - you should try posting your solution on the Adobe knowledge base!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.