简体   繁体   中英

Flex URLStream Security sandbox violation

I want to get URLStream from MJPG, but I have received Error #2048: Security sandbox violation error in release version.

What I'm trying to do:

Security.allowDomain("*");
Security.allowInsecureDomain("*");

var stream:URLStream = new URLStream();
//receiving this error event in onStreamSecurityError handler:
//Error #2048: Security sandbox violation: {swf} cannot load data from {url}
stream.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onStreamSecurityError);
//load method have no loader context option
stream.load(new URLRequest("http://anydomain.com/mjpg/video.mjpg"));

Setting up crossdomain.xml is not the solution cause the application should able to load a stream from any remote server.

As I remember with flash.display.Loader class I set up LoaderContext and application domain. After that flex app can load resources from any domain. But I don't know what to do with URLStream.

Do you have any solution or a workaround of the Error #2048 ?

It's not possible. You can't remotely grant access to another domain, because it's not yours to grant. The allowDomain() function doesn't do that, it does it the other way around:

Lets SWF files in the identified domains access objects and variables in the SWF file that contains the allowDomain() call.

If your SWF is on domain a.com, and you're adding the line Security.allowDomain("b.com") in it, than grants access to a SWF on domain b.com to your SWF. It does not grant you access to domain b.com.

You can find more detailed info on this in the documentation of allowDomain()

AJAX won't let you do that either, or better put, the browser's won't let you. They're all playing by the same rules.

In order to overcome this, you must proxy the request through a server side script sitting on the same domain as your SWF. It can be in PHP with curl, or whatever you find easier. This video explains how and why.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM