12.3 Server-Proofing the Application

The Flash Remoting application has many possible failure points. One of the more frequent failure points is the communication between client and server. Server-proofing involves testing the application in serverless environments to guarantee that the application will fail gracefully if the server is unavailable.

There are many possible reasons for communication failure:

The Internet is too busy

This can happen during peak hours and may be a limitation of the end user's Internet Service Provider (ISP), or it may be tied to a global Internet virus, which seems to occur more and more each year.

The end user has saved the page for offline browsing

If the end user has disconnected from the Internet, how will your application respond?

The server might be down temporarily

This can happen when your ISP is rebooting a server, the server is down for maintenance, etc.

Whatever the reason, your application needs a reliable way to recover from the lack of a connection. In an HTML page, this is not a problem; the browser will force a timeout after a specified number of seconds waiting for a response. In a Flash movie, it is your responsibility to provide a fallback mechanism to handle the lack of a connection. You can do this in two ways:

Provide an offline option in your application

In some applications this is not possible, but you may have an application that works well offline, such as an email program that allows a user to read the contents of previously downloaded email or compose an email offline.

Display a user-friendly error message

The user should not see system error messages and other cryptic messages. Instead, handle the error gracefully in the ActionScript code and display a comprehensible message to the end user.

The System.onStatus event should be assigned to a function in your application so that any failed remote calls will be handled gracefully:

System.onStatus = function ( ) {

This code displays an HTML error page to the user when a connection to Flash Remoting cannot be made.

    Part III: Advanced Flash Remoting