0
votes

I am running a socket server using PHP. The socket server runs fine because I can connect to it using PHP.

Now, I have a flash application that is trying to connect to it:

            this.socket.addEventListener(Event.CONNECT, onSocketConnect);
            this.socket.addEventListener(Event.CLOSE, onSocketClose);
            this.socket.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
            this.socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecError);

            try {
                this.socket.connect("myip", 9999);
            } catch (ioError:IOError) {
                this.debugLbl.text += "ioError1 "+ioError.message;
            } catch (secError:SecurityError) {
                this.debugLbl.text += "secError1 "+secError.message;
            }

When I run the application locally, it works! However, when I upload it to my server I get a sandbox security error (#2048). The flash app is actually hosted on the same server as the socket server, and there is cross domain policy file in place.

3
UPDATE: When I run the flash app, my server actually receives and accepts the socket request. But then the client/flash app shows the sandbox error - Andy Hin

3 Answers

0
votes

Is it possibly you need to use a php proxy? I had to do that, doc'd it here. Although you did mention that the app's on the same server and theres a crossdomain.xml in place, so i'm probably off the mark there (btw, Flash 10 needs a different crossdomain.xml than prev versions as far as I know).

0
votes

Are you actually loading the cross domain policy file? As far as I know, Flash Player only tries to load automatically the following file: http://www.example.com/crossdomain.xml. If your file is in another place, you should load it:

Security.loadPolicyFile("http://www.example.com/subfolder/crossdomain.xml");

Also, even if the app is on the same server, Flash Player believes "http://www.example.com" to be different from "http://example.com", so you should make sure you cover this possibility in the cross domain policy file:

<allow-access-from domain="*.example.com"/>
0
votes

You need to pass the crossdomain.xml file by the socket, because when you work with socket dont work any policy file in the root of the app web.

Here the sample : http://www.blog.lessrain.com/as3-java-socket-connections-to-ports-below-1024/