security sand box error

39 views
Skip to first unread message

cindy

unread,
May 22, 2009, 9:02:01 PM5/22/09
to AS3 HttpClient
on ErrorError #2048: Security sandbox violation:
https://10.3.54.30:4343/screens/switch/HttpStreaming.swf cannot load
data from 10.3.54.30:4343.

If I run the code from Flex build, iut works, but after I copy put the
swf file in to html and load from server, I got the error shown above.
I have put the crossdomain.xml at root to allow access from all domain
and all port. I am using Apache.

Does any one know why?

A lot of thanks!

Code is attached:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" xmlns:cmp="org.httpclient.*" borderStyle="none"
height="500" width="500" creationComplete="initInterface()">
<mx:Script>
<![CDATA[
import com.adobe.net.URI;
import org.httpclient.events.*;
import mx.controls.TextArea;
import mx.containers.Panel;
import mx.controls.Alert;
import asscript.*;

import mx.controls.Alert;
import org.httpclient.*;

var output:TextArea;
var bufferSize:int=1024;
var dataIn:Array=new Array();
var rDataSize:int=0
var count:int=0
var inputByteArray:ByteArray=new ByteArray();

var dataString:String=new String();
var s1:Number;
var s2:Number;

public function initInterface():void
{

output=new TextArea();
output.width=500;
output.height=500;

this.addChild(output);

/* var myTimer:Timer = new Timer(100, 20000);
myTimer.addEventListener("timer", updateUI);
myTimer.start(); */


var client:HttpClient = new HttpClient();

/* client.listener.onStatus = function(event:HTTPStatusEvent):void
{
Alert.show("on status");
};*/

client.listener.onData = function(event:HttpDataEvent):void
{
/* var d:ByteArray = event.bytes;

inputByteArray.writeBytes(d);
count=count+d.length;

if(inputByteArray.length>=bufferSize)
{
updateUI1();
}*/

var d:String= event.readUTFBytes();
rDataSize=rDataSize+d.length;
count=count+d.length;

updateUI3(d);


};

client.listener.onComplete = function(event:HttpResponseEvent):void {
var now2:Date=new Date();
s2=now2.getTime()-s1;
Alert.show("on Complete"+count +"time "+s2+
"array="+inputByteArray.length);
updateUI2();
};

client.listener.onError = function(event:ErrorEvent):void {
var errorMessage:String = event.text;
Alert.show("on Error"+errorMessage);
};

var uri:URI = new URI("https://10.3.54.30/images/spectrumdata");
var now:Date = new Date();
s1=now.getTime();
client.get(uri);
}

public function updateUI(event:TimerEvent):void
{
output.text+=".";
}
public function updateUI2():void
{
/* var iByteArray:ByteArray=new ByteArray();
iByteArray.writeDouble(Math.PI);
iByteArray.position=0;
var k:Number=iByteArray.readDouble();
output.text+=" "+k;*/
inputByteArray.position=0;
do
{
var i:uint=inputByteArray.readByte();
output.text+=i+" ";
}
while(inputByteArray.bytesAvailable!=0);
}

public function updateUI3(s:String):void
{

output.text+=s;
}
public function updateUI1():void
{
var bArray:ByteArray=new ByteArray();
/*if(inputByteArray.length>1024)
inputByteArray.readBytes(bArray,0,1024);*/
output.text+=".";
}

]]>
</mx:Script>

</mx:Application>



Jamie Johnson

unread,
May 23, 2009, 8:13:46 AM5/23/09
to as3-htt...@googlegroups.com
Good morning Cindy.  This is the same issue I was speaking of earlier at http://groups.google.com/group/as3-httpclient/browse_thread/thread/aa53e7dd43639a36.

It boils down to as3httpclient opens ports to a server (even though it's just 80) and any time a client needs to do this within the context you are explaining, it needs to obtain permission from the server, specifically from a socket policy server.  If you debug your application you'll notice an error saying it could not connect to xmlsocket://localhost:80 (this is after trying to connect to port 843, the default).  If you use the 3rd party application found at http://www.flash-resources.net/download.html on the machine where the REST service exists (need to change the default-policy.xml to be the same as your web port), it should work without an issue.
Reply all
Reply to author
Forward
0 new messages