Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
422 views
in Technique[技术] by (71.8m points)

actionscript 3 - How to fix this (probably) cross domain policy error using Flash, Socket.IO and NodeJS

Error #2044: Unhandled SecurityErrorEvent:. text=Error #2048: Security sandbox violation: http://kipos.bluecodestudio.com/holdthebomb/HoldTheBombWeb.swf cannot load data from http://23.29.126.76:8000/socket.io/1/?t=1356891827452.
    at io::Socket/doHandshake()[/Users/airrider3/github/AS3-Socket.IO-XHR-Polling/xhr-polling/src/io/Socket.as:139]
    at io::Socket/connect()[/Users/airrider3/github/AS3-Socket.IO-XHR-Polling/xhr-polling/src/io/Socket.as:110]
    at io::Socket()[/Users/airrider3/github/AS3-Socket.IO-XHR-Polling/xhr-polling/src/io/Socket.as:90]
    at io::IO$/connect()[/Users/airrider3/github/AS3-Socket.IO-XHR-Polling/xhr-polling/src/io/IO.as:36]
    at MainController/endOfbluecodeSplash()[/Users/airrider3/Dropbox/Projects/Kipos/Minigames/HoldTheBombWeb/src/MainController.as:41]
    at bluecodeSplash/endOfSplash()[/Users/airrider3/Dropbox/Projects/Kipos/Minigames/HoldTheBombWeb/src/bluecodeSplash.as:55]
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at com.greensock.core::TweenCore/complete()[D:\_Flash\_AS3srccomgreensockcoreTweenCore.as:178]
    at com.greensock::TweenLite/renderTime()[D:\_Flash\_AS3srccomgreensockTweenLite.as:477]
    at com.greensock.core::SimpleTimeline/renderTime()[D:\_Flash\_AS3srccomgreensockcoreSimpleTimeline.as:93]
    at com.greensock::TweenLite$/updateAll()[D:\_Flash\_AS3srccomgreensockTweenLite.as:642]

I'm using Flash Builder, an ActionScript project, which connects to a server running NodeJS using the Socket.IO module.

To connect Socket.IO with AS3 I'm using the following library https://github.com/sbquinlan/AS3-Socket.IO-XHR-Polling which works perfectly while testing in local, from Flash Builder.

However, if hosted on my domain [http://kipos.bluecodestudio.com/holdthebomb/], I suppose it raises this SecurityErrorEvent because I am not using any crossdomain.xml files correctly? I've never gotten along with this topic, to be honest, so I'm not sure if this is the error.

In any case, I have the following crossdomain.xml file:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
   <site-control permitted-cross-domain-policies="master-only"/>
   <allow-access-from domain="*" to-ports="*"/>
</cross-domain-policy>

I have it in different places on my server. (Should it be on the hosting client?). Yes, the game is hosted on bluecodestudio.com, while the game's server is on the IP 23.29.126.76, running on the port 8000.

If it's the case of the crossdomain policy error, is anyone kind to explain what should be done to fix the problem?

Thanks for your attention.

Update 1:

I set up a server listening on port 843 giving the crossdomain file, but I can see how Flash doesn't try to load it. (I tested the command python -c 'print "<policy-file-request/>%c" % 0' | nc 23.29.126.76 843 and checked how the policy server indeed works.

How come the SWF doesn't try to load a crossdomain policy file?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Crossdomain policy file should be hosted on machine where the server is running i.e. on the 23.29.126.76. For socket connection flash players automatically try to load master crossdomain policy file from the port 843 (You can get simple policy server script from adobe.com http://www.adobe.com/cn/devnet/flashplayer/articles/socket_policy_files.html)

UPD: Use Security.loadPolicyFile("xmlsocket://23.29.126.76:843"); to load policy file directly, but as I wrote flash player already do the same automatically (for port 843), it sends the string request "<policy-file-request/>".

debugging policy

To debug the policy server do the following:

  1. Be sure you have the debug flash player.

  2. Check that server installing is correct by the command (linux, mac or cygwin on Windows): echo -ne '<policy-file-request/>' | nc -v host port. This command should print out your crossdomain.xml file

  3. Turn on the flash player policy log by setting the flag PolicyFileLog=1 in mm.cfg file (be sure you have the debug version of flash player), run swf file and read the policy log, it has user friendly format, you will be able to figure out the problem in most cases by this log.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...