Flex Remoting and WebORB Mysterious Error Messages

If you work with Flex remoting and WebORB, you are probably familiar with the following errors:

  • NetConnection.Call.Failed: HTTP: Status 500
  • Channel Disconnected

You may have tried directing your browser to weborb.php only to get this message: “WebORB v3.5.0 Fatal error: Call to a member function getServiceURI()”

The getServiceURI message is actually a red herring error message.  This simply occurs because weborb.php is expecting the raw headers to contain Flash remoting AMF message data.  Your browser is just making a normal HTTP GET and doesn’t know anything about AMF.   So weborb.php winds up with a null object on which it tries to call getServiceURI().  I wouldn’t be surprised to see a future release of WebORB that catches this error, even though it isn’t the purpose of this particular file to run inside a browser.

So, you are probably frustrated because you were trying to figure out what is wrong with your install and why you are getting the connection and/or channel errors.  These errors are almost always the result of a PHP compile-time error.  PHP5 itself is rather inconsistent in the way it handles different types of errors.  You may have noticed that it’s impossible to catch a syntax error or a bad path in a require_once() statement, for example.  If an include file is missing, PHP craps out before you have a chance to do any error handling.  You can only catch and handle run-time errors within your PHP code.  You may be tempted to think that WebORB should be able to catch these errors and return a more useful message to Flex, however the PHP engine stops executing before it even gives your code or WebORB a chance to handle anything.  It’s kinda the equivelant of having a syntax error in Java or C code that causes your app to not compile.  It doesn’t matter what type of error trapping code you write – if you code doesnt’ even compile, it doesn’t even get the chance to run.

When any part of either your service or WebORB encounters a compile-time error, it instantly dies and, depending on your server config, will write out the error details to STDOUT (which shows in a browser) but what it does not do is return a proper AMF message to the client.  If you were to look at the output of the PHP page, most likely you would instantly see cause of the error.  However Flex/Flash seemingly ignores the output of the page and it only processes the headers returned by the server (ie 500 error).  So PHP is outputing the details of the error but Flex blocks you from reading it.

To figure these errors out, I try to start debugging with a simple function that doesn’t do anything.  Slowly, step-by-step I start re-enabling code until I locate the source of the channel disconnect by process of elimination.  Other times I write a debug page in PHP and call the function in question directly.  (This isn’t always easy if Flex is passing in complex structures, however, it can be worth the effort sometimes).

I’ve noticed these things to be sure-fire causes:

  • require_once statement with file missing (or PHP include path not set right).  Note that if you are dynamically calculating the abolute path of the current working directory that it will be different when you are running via the “Management Console” than if you call your service directly from Flex.  This is a dead giveaway if it runs in one, but not the other.
  • passing in an argument to a method that does not match the declared PHP type.  You can detect this by simply removing your type declaration in your methods and see if the data comes through.  This could indicate a mapping problem or an unsupported type.
  • syntax error that causes PHP compile-time error.  This can be any type of silly syntax error.  These are usually easy to see if you create a server-side page that calls your service method.
  • If the WebORB examples work, but not your own services, it’s pretty much a giveaway that PHP is crashing somewhere inside your own service code and not the WebORB installation.
  • If you can’t even get the WebORB examples to work, then there is a good chance that editing PHP.ini will be required.  If that’s the case, hitting weborb.php with your browser can sometimes show you what’s wrong – just realize that any errors mentioning either getServiceURI() and FlashorbBinaryReader are due to the missing AMF headers that your browser didn’t send and are not the problem.

If you have a better way of debugging, please post a reply.  This can be an extremely frustrating error to chase down and I would welcome any suggestions.

2 Comments

Introducing iTunes De-Dupulator for Windows

iTunes De-Dupulator

>> Download iTunes De-Dupulator 1.0 <<

WARNING: Use this software at your own risk. I recommend backing up your iTunes library file before using this app just in case.  You have been warned!

This is a quick app I threw together this afternoon to help us remove duplicates from our iTunes library at the office.  We’ve all added our own music collection to the office machine and over time it’s become loaded with duplicates.

There’s already other de-dup scripts and applications for iTunes, however they didn’t quite work the way I wanted and so I decided to write one myself.  One thing I wanted was to be able to preview the detected duplicates before deleting them.  This app hunts through the library and adds all potential dups to a table where you can preview them and decide whether or not to delete them.

A feature that I like is being able to ignore certain tracks if they are not within the same album.  There are often legit duplicates of a song, however they appear on multiple albums.  For example a song appears on the artist’s album, but also on a compilation album or a sound track.  Even thought the track is a duplicate, I don’ t like removing them because I prefer to leave all the albums as-is.  iTunes doesn’t have a way to “link” the same song to more than one album, so until then I prefer to leave those dups alone.

Another feature I like is ignoring songs where the length is significantly different.  A lot of times the same song exists but one is an extended mix or a live version.  The option to ignore songs if they are greater than a certain number of seconds different in length helps to filter out those different versions.

F.A.Q

Q. Will this run in OSX?

A. No, however it is possible to open up the same iTunes library using both Windows and OSX.  You need to run Windows as a virtual machine (using Parallels, VMWare, Virtual Box, etc).  Start your virtual machine and open your OSX iTunes music library.  It will say “Updating Library” each time you open it on a different OS but it works fine.

Q. Do you plan to write a native OSX version?

A. No.  I wrote this for my own use and I needed it to run on Windows.  For OSX I recommend  Dupin by Doug Adams, the master of iTunes automation.

Q. What software license is this releases under?

A. The app is freeware with no restrictions on usage or distribution

Q. Will you release the source code?

A. As soon as someone offers to contribute a new feature I’ll create a OSS project.

Known Issues:

  • The app is minimally tested so use at your own risk.  I highly recommend backing up your iTunes library files just in case.  You have been warned!
  • You cannot move the app while it is analyzing the library.  This is because I was too lazy to write the app using threads.  Maybe I’ll look into it later.
  • The app is “always on top.”  I actually find this helpful to operate the iTunes control while going through dups.  Perhaps I’ll add an option in later.
  • After using the app, you may be prompted with a “scripting” warning when you close iTunes.  iTunes will warn you if it thinks another app is using it’s scripting interface.  You can ignore this.

Feel free to leave a reply with any comments or suggestions.

No Comments

FlipCard 2.0 With Source Released

Last year I posted a FlipCard component for Flex that allows you to place UI Controls on the front and back of a 3D “card” that can be flipped by the user.  It gives the user the visual effect that there are settings or options on the backside of the page, form, etc.

FlipCard ScreenShot

Read the rest of this entry »

5 Comments

Insidious Bugs or: How I Stopped Worrying and Learned to Love Exceptions

“Insidious bug” is a term that I use to refers to software defects that are invisible to the end user, but are quietly causing problems behind the scenes.  These errors often occur when a normal bug was either trapped and ignored, or fixed by treating the symptom and not the root cause.  This is also known as bug masking.  I refer to them as insidious when the masked bug is additionally corrupting data.

In my opinion this the most severe type of software bug – far worse than a fatal crash. Users may put in countless hours, weeks, months of data entry before a problem with the data is discovered.  Discovering the cause of insidious bugs can be extremely difficult because there are no indications that the code is failing.  In some cases data may not be recoverable because it was never saved correctly.  Corrupt data can directly cause any number of problems including financial loss, lawsuits, etc.

Keep reading for my personal thoughts on causes and solutions…

Read the rest of this entry »

No Comments

The Info.plist for application at (null) specifies a CFBundleExecutable of (null)

When debugging an iPhone app on the device you may get the error “The Info.plist for application at (null) specifies a CFBundleExecutable of (null), which does not exist”

This can happen if you have dashes in your “product name,” or if the “product name” doesn’t match in your main project info, target info and possibly the name of your target.  The compiler seems to use dashes as a delimiter in the link map and so it causes null errors.

3 Comments