开发者

Flash/Flex & PHP Socket Application Sandbox error

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 serve开发者_如何学Cr 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.


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


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


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜