Wednesday, March 3, 2010

Some Un-reproducible errors with Flex

Here are some errors i've encountered working on the flex and these are not reproducible (rare to see..)


RSL Error when loading application (swf)



Hidden frame for tracking browser history opens up



Famous error 2032



Continue reading the complete post here....




Tuesday, March 2, 2010

Random SOAP Faults in application (Part II - Finding the Cause of problem)

This is in continuation to my last post where some of our end users running low b/w were encountering random SOAP faults in the flex application.

To debug the problem i have requested access to one of the end users machines to see what was going on. Spending good amount of time trying to work with the end users machine didnt give any clue though. I have found that while the end user recieves the SOAP Fault in the flex application, the response sent by the server for that specific request returned just fine with HTTP 200 OK with SOAP body and header looking just perfect in fiddler (http debugging tool). I didnt have a clue on what was going wrong when the response looks perfect.

Next, I took the SOAP body from the fiddler and started looking into the Flex framework, SOAP Decoder to analyze if something is wrong with the response body content, content lenght etc. After spending more time, Everything went through fine. The response was indeed getting decoded fine and everything looks perfect. Since these SOAP Faults were random and cannot be reproducible often, it was making the client frustrating putting us through difficult situations. Time is ticking without any solution yet.

I thought of the idea of trying to deploy a debug build for one release where i enable flex framework logging. I really thought this would give hints to what is happening internally.

Call this function in your creation complete of your flex application and it would enable debugging all the messaging, rpc logs in the framework.

This link would give you complete details on what to do next to enable logging in flashlog file. After I deployed the debug build into a custom environment, I have installed debug version of flash player on couple of end users machines, configured the flashlog settings and asked them to run their tests on this custom environment swf. I should say i was really lucky to get helpful hand from the end users who were willing to nail down this problem as there was no pattern for reproducing the problem.

After couple of days, I got this error SOAP Fault hit once by the end user running the debug flex build. Without any delay i got the flashlog.txt on their machine and looked for the traces of the problem.

Without much help from flexcoders@yahoogroups or the adobe-flex-forums, I spent a lot of time trying to debug through the flex framework to identify the problem. After going through the framework code i have bottomlined it to the fact that the culprit was FIDDLER. The message is not reaching the flash player properly.

This link on the msdn gives how fiddler works. Since fiddler acts like a proxy, messages go and come via fiddler. Unfortunately Client was running old version of fiddler...In some scenarios, even though fiddler recieves the response message fine HTTP 200 OK, it doesnt throw it back to IE properly (so FP doesnt recieve it fine). One of our QA person, running old version of fiddler encountered the problem and the cause was identified by running the same scenario 20 times, with fiddler on, Flex shows SOAP Fault events vs Without fiddler on, it never shows SOAP Faults.

When the end users removed fiddler things started to work since last one week without any random SOAP Faults in the application. It looks to be problem with older version of fiddler 1.x and not with newer versions as we could not reproduce the problem in newer versions. I hope this saves someone's time. I would encourage running network sniffers instead of HTTP Debuggers for debugging purposes for these reasons



PS: The thoughts shared in this blog post are purely experimental based on what we encountered inhouse and may differ


Continue reading the complete post here....




Monday, February 15, 2010

Random SOAP Faults in the application - Part I (Avoiding HTTP 504 errors)

This is in continuation to my earlier post where some of our end users running low B/w were experiencing random soap fault events using our application. I dont have a solution outright but i have made attempts to minimize a lot of these errors


This is the description of the fault errors we were encountering -
  fault String = "SOAP Message cannot be decoded. Raw Response : null"
  fault Code = SOAP Decode Error

So where do i start, what do i nail down? I knew, I wanted to first simulate a low bandwidth in my office machine. Talking to our network administrator was of little or no use (no offense!). I kept googling searching for tools that can reduce the network bandwidth only on my machine. Thanks to Vaideki, who found me this link that helped a lot (a link on raymond's blog archive)


I downloaded Shunra Nimbus from this URL that would exactly simulate a very low bandwidth only on my machine in the network. After installing it, all i have to do is select the speed i want (the reading is in kilobits or divide by 8 for kilobytes) and hit the play button. Browse to the URL http://www.speedtest.net to check the upload and download time.


Now that I have the lowest possible band-width set on my machine, I started to run my application with fiddler on, so i could monitor the http traffic going over the network. Due to very low speed, I have found some interesting results. The amount of time taken to load my swf file (which was around 1.5mb) was really high. I turned on RSLs to reduce the size of my actual swf. This bettered my download time but boom, errors... errors.. errors...


I was seeing them as HTTP 504 Errors in the fiddler. During the creationComplete() were were loading the WSDL's (multiple) and one or two will load fine and then rest will give HTTP 504 errors.


The problem was we were loading multiple wsdl's in a sequence. I changed the code to load these multiple wsdl's sequentially by waiting for LoadEvent.LOAD. After the first wsdl is loaded, it fires the LOAD event and then proceed with loading the second wsdl and so on... This completely got rid of the HTTP 504 errors when running very low bandwidth..




Continue reading the complete post here....




Tuesday, January 26, 2010

FaultEvent.FAULT night-mare when network b/w is low / load is high on the server

I have a task ahead tomorrow to resolve why the flex code randomly hits FaultEvent.fault event handler when the network bandwidth is low and the load on the coldfusion server is high. Watching the HTTP requests through Fiddler (HTTP Debugger) confirms that the request and response packets go through fine without any soap faults / http errors. So the big question ahead is why does some users encounter fault events randomly instead of hitting the ResultEvent.RESULT when the response looks fine on the network http debugger?

Herez a glimpse of what we have -

- We have a CF coldspring implementation exposing webservice operations.
- Flex app loads the wsdl's on load

As the user logs in, we invoke operations on the webservices -

Our end users are running 0.45 Mbps upload and download speeds... Has anyone encountered something like this before? Whats going wrong is a big question for me.... WS code is just a wrapper on the bottom line HTTPService in as. Guess I get a chance to reproduce the scenario and i get to debug through the flex framework to see which piece is actually getting me into this..
Continue reading the complete post here....




Sunday, July 26, 2009

Does size matter?

Gone are those days where we used to tightly stuff a lot of files & folders - setup's, dvd's copies, music collection and some movies into the 20GB HDDs.... These days everything comes in larger sizes. So is Flash Catalyst Beta 1. I was stunned to see the size of it after installation, (is it still a bug? or for real?) - 5.36GB? Wish the number is wrong... wow...



Wondering why its showing "Adobe Flash Catalyst" instead of "Adobe Flash Catalyst Beta 1", hmm... thats a bug... Icon overriding is also a bug...


Continue reading the complete post here....




Saturday, July 25, 2009

Auto doc snippet generation in IDE's...

What is Auto doc snippet generation? Its a very simple feature that i think should atleast be optionally be provided in every IDE tool to enhance overall project coding experience. Let me describe what this simple feature should do (I am not aware of any tool/plugin which is already available so far)...

     Just as you declare a variable, and just as you are done, ';' should auto generate the doc skeleton, create a //TODO:write comment snippet auto-select it and get you ready to just type what it is supposed to do.

        

    Just as you write a function and as you "}" (close) the function, it should auto generate the doc skeleton, create a //TODO:write comment snippet auto-select it and get you ready to just type what it is suppsed to do. As you change your function signature it should introspect existing doc skeleton and alter the argument types, return types etc. without having to manually go and edit it.

   

    

    Just as you close a loop (ex: for, while etc.), it should auto generate the doc skeleton, create a //TODO:write comment snippet auto-select it and get you ready to just type what the logic is for..

     

    Just as you write an if condition, it should auto generate the doc skeleton, create a //TODO:write comment snippet auto-select it and get you ready to just type what this condition is for..

      

     I've worked on a lot of projects but none of the projects were fully documented. Every developer has his/her own way of writing a piece of code. Even when you have a code monitoring tool, peer code review process, strict code guidelines to follow on every project (which is predominently seen in product based companies than services based companies and a less often in some companies who just want to get things working without having to bother much about spending time in writing code comments), there is always a scope of the code being written is left undocumented. There are some companies who enforce strict documentation on the code written but at the end they see themselves doing just 50-60% of it overall. I would say there are atleast 70% or more of the larger audience who concentrate on putting their brain at work by writing the actual code and get things working and leave their baby code undocumented unintensionally due to other work priorities. Developers may change and a new developer joining in is always targetted to face the tough time with the gaint code. Even the developer who wrote the code 4 months ago doesnt completely remember what's written unless he spends some time by going through the code again.

    How does a fully-documented code look like? Many people like to read the lines of code as they glance it and seeing a lot of comments written due to auto-doc snippet generation sometimes might disturb them. I do agree, but we can always have preference options to show/hide doc snippets, fold/unfold doc snippets.. everything is possible. As the application code grows larger and larger with tons of frameworks out there, the code is crying out loud - "If you dont document me now, i'll kill you or someone in the long run"...


Continue reading the complete post here....




Wednesday, July 22, 2009

Life Cycle Data Services 3 - New !!

With Adobe's showering a bunch of products into beta (almost at the same time), CF9, CFBuilder, FlashBuilder, FlashCatalyst, Flex4, LCDS3... wow..thats a lot.... Yesterday i had a chance to look at the video tutorials posted on the labs for the new lcds 3 beta features. Adobe's Romania team scores high in delivering these server spice into flex. From my LCDS 2.5+ experience, this was really a new ball game. Here are some of the highlights -

  • Model driven development brought into Flex with Fiber (language?)... Model View perspective in flash builder (earlier flex builder), create models from the RDS View connected to db from within flash builder, create services for the operations, generating model driven forms from within flash builder to quick test your model
  • Easy creation of filters from within flash builder
  • Annotations
  • localization, validation, data formats
  • Reliable messaging - this is one of the best features. Having AdvancedChannelSet, AdvancedMessaging This feature ensures that messages sent over the wire do not get dropped out due to network fluctuations (on and off). Before it tries to give you a feedback saying message sending error it does try to resend it for some time (configured) so it gets around the problem of fluctuating networks.
  • Message Throttling - Video streams for bad network are always hit. With this feature, you have more control on how your data messages can be handled with care to ensure to fit it in your network. You have options to pamper the inbound messages and outbound messages. InBound Messages have policy options - ERROR, IGNORE, NONE and OutBound Messages have policy to ERROR, BUFFER, NONE..

Its amazing to see the new developments...


Continue reading the complete post here....




Converting AS Objects to XML and reading the same XML into AS Objects...

One of the requirements i had was to write down the Action Script object returned from the Coldfusion webservice call into a flat xml file. This was a temporary solution i had to provide seamless integration between flex app and AIR app..

I had a huge bunch of query object data returned through CF webservice call and i needed to persist the data into an xml file without having to write a whole bunch of code to navigate to each and every property of the object (introspect)...

    This simple code here lets you write the crude CF returned object into a nice XML

   And this code below converts the XML into an action script object that can be used during your persistence..



Continue reading the complete post here....




Invoking JavaScript from Flex AIR App (in FlexBuilder)

This is with FlexBuilder3. If you have a lot of javascript source files made on another project of yours (presuming to have used another technology like CF, .NET, Java) and you are intending to use those javascript source files while porting to Flex based AIR Application, then here is a sample to load all your javascripts and invoke the functions from With in the Flex application.

"Note: Adobe AIR currently does not support the ExternalInterface class" is clearly indicated in the API. So whats the alternative to this.

The API link for ExternalInterface.as (Search in AllClasses for ExternalInterface.as) also clearly indicates the following are possible:

From ActionScript, you can do the following on the HTML page:

  • Call any JavaScript function.
  • Pass any number of arguments, with any names.
  • Pass various data types (Boolean, Number, String, and so on).
  • Receive a return value from the JavaScript function.

So What we are going to do is "Load a dummy html page carrying links to all the javascript files to be invoked from the Flex AIR Application"...

Step 1: Get your js files into a directory

Step 2: Create a dummy html file and include your scripts as here

Step 3: use <mx:HTML /> tag of Adobe AIR to reference it in your app

Step 4: On Creation complete handler of your Adobe AIR application, load the html file which contains your js files, so you can reference it later on to invoke javascript functions...

Step 5: Use the reference as below and invoke a javascript function from within flex. You can pass arguments to the js function and retrieve return values as well.



Continue reading the complete post here....




Tuesday, June 30, 2009

Reading .sol (SharedObjects) created by Browser Flex App in a new AIR Application - Seamless integration? Web & Desktop?

    One of the requirements was to provide seamless integration between the browser flex application serving the client needs when the network is on vs an AIR Application as an offline system when the network turns off. But the requirement isnt straight as you think. What it says is, When network is connected the end user will be using flex browser application by navigating to the URL which downloads a lot of data on to the client machine from the server which periodically gets updated based on the data-change on the server. This is stored as client side SharedObjects through the browser ran flex app. Now when the network turns off, the end user would launch the offline system that should read through earlier created sharedobjects while network was on and work through it. AIR App should also be able to write a shared object containing data required to be parsed through the browser flex app when launched (when network is back)...

    This kind of sounds so wierd to me. After hearing the requirement, i was like WHAT?? But then i started to see through different ways of achieving it. With Browser Sandbox Security, browser flex app always can get hold of SO (Shared objects) created through SharedObject.getLocal(). Even if we were to understand and agree to one common location that AIR Could understandably read, keeping the location parameter excluded for a whole lot of argument... The Important thing is to consider serialize and de-serialize a FileStream read ByteArray into AS Objects that can be natively used in the code. Well, more to that is the SharedObjects written through the browser flex app could also carry complex data structures which could carry more information rather than a simple data->name/value

   While doing the research, i went through a lot of google search - .minerva was exactly doing what i was looking for but its not open to go through the bits of it and tweak to get it working !!

Here is a sample code demoing the problem:

 


Browser Flex App creates a shared object (typed ClazzTest.as containing two public variables value1 and value2 of type string)

AIR App code that tries to read the shared object created by the browser flex app above.. (for now assume that the object location is hardcoded)

The above AIR App code doesnt work. Its just the way i wish it would. But i believe we need to go through the entire signature of SharedObject and read the bytestream in the way SharedObject is defined as an entirety like header, body etc. I just looked at the Serializer and Deserializer in AMF-PHP and that just gives me some idea. Trying to do this entirely might take a long time than to get it just working quickly... I am still on a hunt !! ------------------------------------------ If someone is looking out for a quick solution where in you wont have enough time to write an AMF object parser, you can follow my quick solution. We lowered the IE settings to allow scripting, there by i invoke a javascript function which writes the data to the flat xml file in the client machine from the flex application through ActiveXObject(), and these flat .xml files are read by the AIR app later on. Atleast this seems to work fine for me until i converge on a right solution !!


Continue reading the complete post here....




Thursday, June 11, 2009

Flashplayer ScriptTimeOutError, A Script has executed longer than 15 seconds

While doing Load testing of the flex application we've developed, we hit upon this scenario where our test load data was so huge that optimizing DB queries, webservice logic, client logic took us more than 60 seconds which is the maximum timeout limit Flashplayer can be increased to.

To find a solution to the problem, I have googled around and found some interesting articles.

When the load data is so huge, and you are tired of optimizing code just to fit in the 60 seconds time intervel before the timeout error is thrown by flash player... I tried to workaround it with a solution that will run for enough time without freezing / breaking your load data...


Here is the sample Flex code that would throw the Flashplayer script timeout error.

Error message -

My Solution to this problem is to workaround by giving flashplayer a breathing time. This is however not a full-fledged code but would completely give you an idea on what i am trying to achieve. The below code would run a timer for say 100 milli-seconds and execute your piece of code which you think is consuming more time... say if you are iterating over 10,000 items with a lot of data or something similar... This solution would run a timer and call it over and over until your job execution is done, when you delete the listener and proceed further with your logic. This way flashplayer break due to heavy load is taken care of. Flash player would get a breathing time to perform any UI operations if any meanwhile. In my actual code at work, i display a popup modal window before the timeconsuming operation begins that displays - "Please wait, while we are processing the data", and i remove the modal dialog once the entire process is done. This way end user feels that he has a feedback from the app and even if it were to take a bit more time, this solution will scale for you even if your load were to increase in more numbers...

See the Solution here (Iterating based on a timer until execution is complete)...


Continue reading the complete post here....




Saturday, June 6, 2009

First Look at Flash Builder 4 (Beta1)

I wanted to list down my first feel of launch of FlashBuilder4-Beta1 and how it made different from FlexBuilder3. This post is not intended to list down all the differences between FlexBuilder4Beta1 and FlashBuilder3 but however, it is only intended to get the FIRST FEEL DIFFERENCE of your regular FlexBuilder3 and FlashBuilder4 Beta1

Name Change of FlexBuilder perspective to Flash - (Flash vs Flex Development, Flash Debug vs Flex Debugger, Flex Profiling vs Flash Profile)

New Start Page

First thing, you do is to right click on the Package Explorer and create a new project. As you rightclick you see new entry "Execute FlexUnit Tests". FlexUnit integrated into flex builder... New->Test Case Class, New-> Suite Class are also new entries.

New Panels - Data/Services, Network Monitor...

New Data-Connect wizards...

Blaze DS (integrated option)

Fx icon changed to f with new Flex 4 libraries

New Enhanced Package Explorer, Shows package view, Flex4 lib....

 AS Doc as soon as you try to open up type on the tag name through the code hinting dialog. ASDoc panel which shows docs. Its one of the best features that has been missing for a long time (ofcourse driven from java perspective - eclipse)

<mx:script> changed to <fx:script>

Auto-Generation of event handlers from within flex builder...auto-generated click event handler for the button..

AsDoc comment....

and a lot more....


Continue reading the complete post here....




Installing FlashBuilder4 Beta1 (Earlier FlexBuilder)

Step by Step - Installing Flash Builder Beta 1 (Earlier Flex Builder)

 

 



Continue reading the complete post here....




Tuesday, June 2, 2009

Flex SDK 4, Flash Builder 4, Flash Catalyst (earlier Thermo) - Beta1 Launch

     Well, old news first - Flex SDK 4, Flash Builder 4 (Earlier Flex Builder 3) and Flash Catalyst (Earlier called Thermo) are now available on labs.adobe.com for BETA1. I've atleast waited for this release since long. With Flash Catalyst, Adobe brings a lot to the community in terms of new roles - Flex Designer, Sr. Flex Designer, Flex Designer - Architect etc. - new opportunities adding new jobs to the market sunk in recession and above all, it takes Flex/Flash to a whole new dimension enchanting that no two applications in the market should look alike with the default halo theme... Explore the richness of each application, design appealing UIs that make your application uniquely shiny, and extra-ordinary... A lot is already said about already about whats new and all... some of them i came across are - sujit, tim buntel , matt chotin, whats new flex 4 - dev specs with examples, sean moore etc.



Continue reading the complete post here....




Monday, April 13, 2009

Slide Move Effects to your Flex Components

I was just playing around with a simple effect in flex that gives you a slider feeling... how you slide your closet? This is pretty simple and many starters would already know. I was just playing with it to see how i can create dynamic elements and have those dynamically created elements play this effect.

Simple Plain code

 




 

 
 
  
   
  
  
   
  
  
   
  
  
   
  
 
 
 


 

      private function onClickNext():void
      {
       var xByValue:Number = -455;
       loopNavigator.xBy = xByValue; 
       
       loopNavigator.play([panel1, panel2, panel3, panel4]);
      }
      
      private function onClickPrevious():void
      {
       var xByValue:Number = 455;
       loopNavigator.xBy = xByValue; 
       
       loopNavigator.play([panel1, panel2, panel3, panel4]);
      }

This is how the output would look like (crude form)

 

Dynamically added Elements will now animate with this code (crude form)

   import mx.controls.Text;
   import mx.containers.Panel;
   import mx.effects.easing.Bounce;
   
   public var tmpPanelElements:Array = new Array();
   
   private function onCreationComplete():void
   {
    var tempArray:Array = getTempArray();
    for(var i:int = 0; i < tempArray.length; i++)
    {
     var panel:Panel = new Panel();
     panel.width = 400;
     panel.height = 400;
     panel.id = 'panel' + i;
     
     var text:Text = new Text();
     text.text = 'text' + i;     
     panel.addChild(text);     

     panelContainer.addChild(panel);
     tmpPanelElements.push(panel); 
    }
   }
   
   private function getTempArray():Array
   {
    var tempArray:Array = ['one', 'two', 'three', 'four'];
    
    return tempArray;
   }
   
      private function onClickNext():void
      {
       var xByValue:Number = -455;
       loopNavigator.xBy = xByValue; 
       
       loopNavigator.play(tmpPanelElements);
      }
      
      private function onClickPrevious():void
      {
       var xByValue:Number = 455;
       loopNavigator.xBy = xByValue; 
       
       loopNavigator.play(tmpPanelElements);
      }


Continue reading the complete post here....