Getting Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. (despite valid URL)

Hello,

The below scrip throws an error after:
 loader.load(request)

I attached the project that you can import with the folder option of the import project window after unziping (change the extension to *.7z instead of *.txt)

Here is the trace:

[HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=0 responseURL=null]
Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: https://graph.facebook.com/PacktPub
      at controllers::CustomGraphContainerController()[C:\wamp\www\books\Facebook Graph API Development with Flash\Flash Builder\Chapter2_Start\src\controllers\CustomGraphContainerController.as:14]
      at Main/setUpGCC()[C:\wamp\www\books\Facebook Graph API Development with Flash\Flash Builder\Chapter2_Start\src\Main.as:71]
      at Main/init()[C:\wamp\www\books\Facebook Graph API Development with Flash\Flash Builder\Chapter2_Start\src\Main.as:34]
      at flash.display::DisplayObjectContainer/addChildAt()
      at flash.display::Stage/addChildAt()
      at Preloader/startup()[C:\wamp\www\books\Facebook Graph API Development with Flash\Flash Builder\Chapter2_Start\src\Preloader.as:61]
      at Preloader/loadingFinished()[C:\wamp\www\books\Facebook Graph API Development with Flash\Flash Builder\Chapter2_Start\src\Preloader.as:55]
      at Preloader/checkFrame()[C:\wamp\www\books\Facebook Graph API Development with Flash\Flash Builder\Chapter2_Start\src\Preloader.as:43] Chapter2-Start.txt
public function CustomGraphContainerController(a_graphControlContainer:GraphControlContainer)
		{
			super(a_graphControlContainer);
			var loader:URLLoader = new URLLoader();
			var request:URLRequest = new URLRequest();
			request.url = "https://graph.facebook.com/PacktPub";
			loader.addEventListener(Event.COMPLETE, onGraphDataLoadComplete);
			loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHttpStatusMessage);
			loader.load(request);
		}
		
		private function onGraphDataLoadComplete(a_event:Event):void 
		{
			var loader:URLLoader = a_event.target as URLLoader;
			var graphData:String = loader.data;
			trace(graphData);
		}
		
		public function onHttpStatusMessage(event:HTTPStatusEvent):void
		{
			trace(event.status + " -- " + event.toString());
		}

Open in new window

deve-lopezAsked:
Who is Participating?
 
dgofmanConnect With a Mentor Commented:
Your goal running Flash Player as standalone application. Convert SWF->EXE?
0
 
dgofmanCommented:
you file is corrupted
0
 
deepanjandasCommented:
ioerror actually means the file is not present.
Can you directly call and access the page you are trying to load. Try loading that directly in browser and see first.

Warm Regards
Deepanjan Das
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
deepanjandasConnect With a Mentor Commented:
May be add a IOError handler also:
loader.addEventListener(IOErrorEvent.IO_ERROR, onError);

private function onError(event:IOErrorEvent):void 
{
        trace(e);
}

Open in new window


Warm Regards
Deepanjan Das
0
 
deve-lopezAuthor Commented:
Yes the URL works.
I tried to run this from the disk and from a web host with a crossdomain.xml file but the issue remains.
I am on Windows XP with the latest CS5 installed by the way.

here is the result after tracing the IO_ERROR:

0 -- HTTPStatusEvent: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=0 responseURL=null]

 -- IOErrorEvent: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: https://graph.facebook.com/PacktPub"]
0
 
dgofmanCommented:
I think facebook checking user-agent header. What you cannot pass from Flash Player its available via AIR. But you can get responce using navigateToURL

var request:URLRequest = new URLRequest("https://graph.facebook.com/PacktPub");
navigateToURL(request, "_blank");

Workaround using PHP on your remote server and simulate browser agent using curl API's
0
 
dgofmanCommented:
But if you want to use Facebook API you may need to use google code library

http://code.google.com/p/facebook-actionscript-api/
0
 
deepanjandasCommented:
When I run the Main.html, I see no errors.
Is that the file to test with?

Warm Regards
Deepanjan Das
0
 
dgofmanCommented:
You will not see an error when you ran locally, but at same time loader.data is null.

deve-lopez, looks like wants to parse JSON file. He cannot use URLLoader in this case.

He may need to write JavaScript API and communicate with Flex using External APi or use Facebook API's for Flex
0
 
deepanjandasConnect With a Mentor Commented:
Hi @dgofman, I am not sure why json data cannot be loaded using URLLoader.
Afterall the data will be a string and needs to be converted to JSON in the handler like this:

var data:Object = new JSONDecoder( event.data, true ).getValue();

But this error i guess has nothing to do with the type of data returned.

Warm Regards
Deepanjan Das
0
 
dgofmanCommented:
Many web services validation an USER-AGET header.
For example Apple, you will never ever will able to download any applications from App Store if your browser is not running IPhone or IPad (whats is WebKit)

So, Facebook filtering request and sending NULL if user-agent is Flash Player
0
 
deve-lopezAuthor Commented:

I added the User-Agent to the Request but it does not look like it changes anything.
Using a network traffic monitoring tool I can confirm that the issue is in the FlashPlayer the request is never sent over the wire. Conclusion some lame security crap code is the problem.
Did anyone tested the project I uploaded succesfully on a windows XP machine?
I am asking cause I wonder if this is a bug on XP, I bet they did not test the latest Flash Builder on XP at Adobe... Let me know as this is driving me nuts...
What a waste of time for something that should be trivial...

Thanks to all of you for trying with me, let's solve that puzzling issue once for everyone else ;-)
0
 
deve-lopezAuthor Commented:
Updated sample code with the User-Agent header set:

request.url = "https://graph.facebook.com/PacktPub";
var header:URLRequestHeader = new URLRequestHeader("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 YFF35 Firefox/3.6.15 ( .NET CLR 3.5.30729; .NET4.0E)");
request.requestHeaders.push(header);
loader.addEventListener(Event.COMPLETE, onGraphDataLoadComplete);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHttpStatusMessage);
loader.addEventListener(IOErrorEvent.IO_ERROR, error_handler);
loader.load(request);
0
 
dgofmanConnect With a Mentor Commented:
Ok, finnaly I got JSON responce as string

<fx:Declarations>
   <mx:HTTPService id="srv" url="https://graph.facebook.com/PacktPub" result="onResult(event)"/>
</fx:Declarations>

private function onResult(event:ResultEvent):void{
      trace(event.result);
}

public function CustomGraphContainerController()
{
    srv.send();
}
0
 
dgofmanConnect With a Mentor Commented:
hi  deve-lopez,
I don't know how are you able to execute your script on Flash Player using  "URLRequestHeader"  "User-Agent","Mozilla/5.0"
It was throw Error in my debugger.

Any way if you want to resolve your problem you need just add a sigle line:


var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("https://graph.facebook.com/PacktPub");
request.contentType = HTTPRequestMessage.CONTENT_TYPE_FORM;
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE, onGraphDataLoadComplete);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHttpStatusMessage);
loader.load(request);
0
 
dgofmanCommented:
Hi deve-lopez,

I think request.contentType = "application/x-www-form-urlencoded";

should solve your problem.

Please can you update your status or close this question.

Thanks,
David
0
 
deve-lopezAuthor Commented:
@David
Hi!
I will try all your suggestions as soon as I can.
Thanks, D.
0
 
deve-lopezAuthor Commented:
The attached code is correct and works great on Mac but strike a security error on Windows XP.
Obviously Adobe made little testing of their player on XP, with more than 50% of the PC on the planet still running XP that sounds like a serious flaw for a product that market itself as the ultimate cross-platform solution.

Is there a way to flat out disable permanently all Flash security mechanism for a given flash project/executable?
package controllers
{
	import ui.GraphControlContainer;
	import flash.events.Event;
	import flash.events.HTTPStatusEvent;
	import flash.events.IOErrorEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.URLRequestHeader;
	
	public class CustomGraphContainerController extends GCController
	{
		
		public function CustomGraphContainerController(a_graphControlContainer:GraphControlContainer)
		{
			super(a_graphControlContainer);
			var loader:URLLoader = new URLLoader();
			var request:URLRequest = new URLRequest();
			request.url = "https://graph.facebook.com/PacktPub";
			loader.addEventListener(Event.COMPLETE, onGraphDataLoadComplete);
			loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHttpStatusMessage);
			loader.addEventListener(IOErrorEvent.IO_ERROR, error_handler);
			loader.load(request);
		}
		
		private function onGraphDataLoadComplete(a_event:Event):void 
		{
			var loader:URLLoader = a_event.target as URLLoader;
			var graphData:String = loader.data;
			trace(graphData);
		}
		
		public function onHttpStatusMessage(event:HTTPStatusEvent):void
		{
			trace(event.status + " -- HTTPStatusEvent: " + event.toString());
		}
		
		public function error_handler(event:IOErrorEvent):void
		{
			trace(" -- IOErrorEvent: " + event.toString());
		}
		
	}

}

Open in new window

0
 
dgofmanConnect With a Mentor Commented:
Hi deve-lopez,
I don't have WindowXP at home, but I was able to run code bellow on Windows 7 as SWF ans EXE.
I attached archive ZIP file, change extention from PNG - > ZIP


package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.HTTPStatusEvent;
	import flash.events.IOErrorEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.URLRequestHeader;
	import flash.text.TextField;

	public class CustomGraphContainerController extends Sprite
	{
		private var _log:TextField;

		public function CustomGraphContainerController()
		{
			super();
			_log = new TextField();
			_log.multiline = true;
			_log.wordWrap = true;
			_log.width = stage.stageWidth;
			_log.height = stage.stageHeight;
			addChild(_log);

			var loader:URLLoader = new URLLoader();
			var request:URLRequest = new URLRequest();
			request.url = "https://graph.facebook.com/PacktPub";
			request.contentType = "application/x-www-form-urlencoded";
			loader.addEventListener(Event.COMPLETE, onGraphDataLoadComplete);
			loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHttpStatusMessage);
			loader.addEventListener(IOErrorEvent.IO_ERROR, error_handler);
			loader.load(request);
		}
		
		private function onGraphDataLoadComplete(a_event:Event):void 
		{
			var loader:URLLoader = a_event.target as URLLoader;
			var graphData:String = loader.data;
			_log.appendText(graphData + "\r\n");
		}
		
		public function onHttpStatusMessage(event:HTTPStatusEvent):void
		{
			_log.appendText(event.status + " -- HTTPStatusEvent: " + event.toString() + "\r\n");
		}
		
		public function error_handler(event:IOErrorEvent):void
		{
			_log.appendText(" -- IOErrorEvent: " + event.toString() + "\r\n");
		}
		
	}
	
} 

Open in new window



CustomGraphContainerController.png
0
 
deve-lopezAuthor Commented:
Thanks for your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.