I am working on this side project in Flex that I need to use PHP and curl (code is very similar to this) to delegate my http calls to some RESTful services. While I debug it from Flash Builder IDE, everything works fine; but when I put my release build to the server, I get the following errors:
[RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:37813/views/INLINE/rows.json?accessType=API&method=clustered2&min_lon=-89.761262&min_lat=41.700473&max_lon=-85.806184&max_lat=42.294452&target_node_clusters=250&min_distance_between_clusters=0.005188813084372479&https=Y]. URL: https://data.cityofchicago.org/views/INLINE/rows.json?accessType=API&method=clustered2&min_lon=-89.761262&min_lat=41.700473&max_lon=-85.806184&max_lat=42.294452&target_node_clusters=250&min_distance_between_clusters=0.005188813084372479"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:345]
at mx.rpc::Responder/fault()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\Responder.as:68]
at mx.rpc::AsyncRequest/fault()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:113]
at DirectHTTPMessageResponder/errorHandler()[E:\dev\4.y\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:410]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
To debug, I went back from the very beginning and tested my DAO interfaces one method after another until I nailed down to the following error. The reason is that requests through an HTTPService through the aforementioned proxy with its headers property specified will trigger the following sandbox violation (Flash Player 11.2.202).
myHTTP.headers = {Accept: "application/json"};
or
var header:Object=new Object();
header["Accept"] = "application/json";
myHTTP.headers = header;
[RPC Fault faultString="Security error accessing url" faultCode="Channel.Security.Error" faultDetail="Destination: DefaultHTTP"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:345]
at mx.rpc::Responder/fault()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\Responder.as:68]
at mx.rpc::AsyncRequest/fault()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:113]
at DirectHTTPMessageResponder/securityErrorHandler()[E:\dev\4.y\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:437]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/redirectEvent()
As my proxy already specifies the headers of my calls (‘Accept: application/json’, ‘Content-type: application/json’, “X-App-Token:XXXxxxxXX”), there doesn’t seem a need to specify this headers property for any HTTPService used in Flex at all.