CELEBRATE EARTH WEEK
Save 40% on eBooks and Web Editions*—use code EARTH now through April 27. Shop now.
Publishers of technology books, eBooks, and videos for creative people
A wonderful addition to Flash Builder is its Network Monitor, a tool for detailed reporting of all Flex-server communications. The Network Monitor can be used to test, debug, and improve the use of Web services in your Flex applications. You'll learn everything you need to know about this valuable new tool in this post.
To start, activate the Network Monitor panel (select Window > Network Monitor if it's not already among the choices at the bottom of the workbench). I should note that the Network Monitor is only available in the Premium edition of Flash Builder, however.
To enable the Network Monitor for the current project, click the first icon in the upper-right corner of the Network Monitor panel (Figure 1).
You can also suspend the monitor (the second icon) and clear the monitor results (the third icon). When the monitor is enabled, the first button can be clicked again to disable it. You should always disable the Network Monitor before exporting the final version of a project!
One thing to be aware of with the Network Monitor is that it's likely to affect the performance of the application. This makes sense, because you're adding an extra layer of inspection on all outgoing and incoming transactions. For simple services, the delay may not be bad or even noticeable, but for complex services, such as using AMF (Action Message Format), the delay can be quite pronounced. This is another reason to make sure you disable the Network Monitor before taking a Flash application live!
The next step is to run your application and then use it in such a way that some service calls are made. You can close the application and return to Flash Builder or just switch back to Flash Builder to see the results in progress (in that case you'll see a "Recording..." message in the Network Monitor). On the left side of the Network Monitor, you’ll see a list of every server call, including the URL, the service type (HTTPService, RemoteObject, etc.), the times (started, ended, elapsed), and the operation type (Figure 2).
This is a great start for just seeing what happened. You can also use the information to confirm that no service call is taking an unreasonable amount of time.
If you click on one of the values in the URL column, you can see the details of that transaction. Those details will appear on the right side of the window, with one tab for the particulars of the client request and another tab for the particulars of the server response. Each tab shows valuable information, from the size of the transaction in bytes to the actual data conveyed, including data posted to a server (Figure 3).
If the data is being transmitted via AMF (Action Message Format), the Network Monitor will even decode it so it's legible. The transaction data is recorded for both successful and unsuccessful calls, so the Network Monitor can help you quickly see the problem with a failed call. For example, if the server experienced an error, it'll be indicated in the response tab.
If you find the logged results to be useful, you can click the save icon (the fourth one in Figure 1) to save them as an XML file, perhaps to compare those results with later ones after tweaking the code.
In previous versions of Flex Builder, or if you're not using Flash Builder Premium, developers had to use a third-party proxy service in order to have this same level of server reporting. Thanks to the new Network Monitor, valuable debugging and profiling information is now readily available in the IDE itself.