Solved

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

Posted on 2011-03-17
20
5,714 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:deve-lopez
  • 10
  • 6
  • 4
20 Comments
 
LVL 29

Expert Comment

by:dgofman
Comment Utility
you file is corrupted
0
 
LVL 17

Expert Comment

by:deepanjandas
Comment Utility
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
 
LVL 17

Assisted Solution

by:deepanjandas
deepanjandas earned 166 total points
Comment Utility
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
 

Author Comment

by:deve-lopez
Comment Utility
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
 
LVL 29

Expert Comment

by:dgofman
Comment Utility
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
 
LVL 29

Expert Comment

by:dgofman
Comment Utility
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
 
LVL 17

Expert Comment

by:deepanjandas
Comment Utility
When I run the Main.html, I see no errors.
Is that the file to test with?

Warm Regards
Deepanjan Das
0
 
LVL 29

Expert Comment

by:dgofman
Comment Utility
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
 
LVL 17

Assisted Solution

by:deepanjandas
deepanjandas earned 166 total points
Comment Utility
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
 
LVL 29

Expert Comment

by:dgofman
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:deve-lopez
Comment Utility

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
 

Author Comment

by:deve-lopez
Comment Utility
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
 
LVL 29

Assisted Solution

by:dgofman
dgofman earned 334 total points
Comment Utility
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
 
LVL 29

Assisted Solution

by:dgofman
dgofman earned 334 total points
Comment Utility
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
 
LVL 29

Expert Comment

by:dgofman
Comment Utility
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
 

Author Comment

by:deve-lopez
Comment Utility
@David
Hi!
I will try all your suggestions as soon as I can.
Thanks, D.
0
 

Author Comment

by:deve-lopez
Comment Utility
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
 
LVL 29

Accepted Solution

by:
dgofman earned 334 total points
Comment Utility
Your goal running Flash Player as standalone application. Convert SWF->EXE?
0
 
LVL 29

Assisted Solution

by:dgofman
dgofman earned 334 total points
Comment Utility
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
 

Author Closing Comment

by:deve-lopez
Comment Utility
Thanks for your help
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now