Error handling in Flash Remoting for AS 2.0
Todd Hivnor <[email protected]> Tue, 21 Mar 2006 11:42:54 -0800
| Newsgroups | gmane.comp.java.openamf.user |
|---|---|
| Message-ID | <[email protected]> |
I have been migrating from AS1.0 to AS2.0, and have been having troubles
with the new Flash Remoting. It seems to do a very poor job of error
reporting ... even worse than the error reporting in the old AS1.0
version of Flash Remoting. I'm wondering if anyone knows of any tricks
on how to get notification if the remote server is down.
If the remote server is not reachable, I don't get any error at all. The
RelayResponder never calls my error handler. I've started from the
sample Remoting code, straight from the Macromedia docs. The source code
is below. I did update the library to include the "RemotingClasses"
component, and the code works when I am use a valid URL. But, if I stop
my 'localhost' server, or use the Macromedia server (which is now
defunct), the RelayResponder never calls my error handler.
Note that if the server is totally unreachable, I do see "Error opening
URL..." in the trace window. If the server is reachable but returns
HTML, like the Macromedia server is doing, I get nothing. Adding a
logger is no help, as no log statements are generated when trying to
connect to the unreachable server.
In AS1.0, I used to define _global.System.onStatus and
NetConnection.onStatus. One of them would get called if there was a
basic connection error. Perhaps there is something similar for the new
AS2.0 Flash Remoting?
I'd really love to get to the bottom of this. Thanks in advance for any
clues - Todd
--------BEGIN AS CODE----
import mx.remoting.Service;
import mx.remoting.PendingCall;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
import mx.rpc.RelayResponder;
mx.remoting.debug.NetDebug.initialize();
var url : String;
//url = "http://localhost:8080/InsightXP-r999/AdvancedGateway4";
url = "http://examples.macromedia.com/flashservices/gateway";
var myService:Service = new Service(
url, null,"petmarket.api.catalogservice", null, null); // connect
to remote service
trace("Connecting ...");
var pc:PendingCall = myService.getCatagories({locale:"en_US"}); // call
service method
pc.responder = new RelayResponder(this, "getData_Result", "getData_Fault");
function getData_Result( re:ResultEvent ):Void { // receive result
trace( "getData_Result: got the response" );
}
function getData_Fault( fe:FaultEvent ):Void { // receive fault
trace( "getData_Fault: " + fe.fault.description);
}
--------END AS CODE----
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642