Using openAMF (and I assume other remoting solutions) when the gateway is up but you send an erroneous request the responder.onFault method is called with the details of the error. However if the gateway is not up or you have a bad port/ip address the onFault method of the responder is never called.
Jim Cheng on the flashcoders list suggested making a callback to the global onStatus method :
_global.System.onStatus = function(statusObj:Object):Void {
if (statusObj.code == 'NetConnection.Call.Failed') {
// The server is down or has become unresponsive.
// Insert additional code per your application here.
}
}
This works, but I needed control a individual service call. I use the ARP framework but it essentialy typical actionscript 2 calls to remoting :
First I created an interface to add a new 'onGateWayDown' method
interface com.nscorp.util.remoting.NSResponder extends mx.rpc.Responder
{
// add a failure
public function onGatewayOffline():Void;
}
and now my responder class for a particular service
class LoginResponder implements NSResponder
{
public function onGatewayOffline():Void
{
trace("The gateway is down !");
}
public function onResult (resultObj:ResultEvent):Void
{
trace("got some data);
}
public function onFault(faultObj:FaultEvent):Void
{
trace("got a fault");
}
}
So now to call my service and handle thing appropriately :
var responder:NSResponder = new LoginResponder();
var authenticationService:Service = new Service ( "http://foo.foo.com?gateway2", null, "AuthenticationService", null, null );
authenticationService.connection.onStatus = responder;
var pendingCall:PendingCall = service.authentication("someName", "somePassword");
pendingCall.responder = responder;
Now if a fault occurs my onFault method of the LoginResponder is called AND if the gateway is down and the call times-out the onGateWayDown method is called.
This isn't documented too well within macromedias site.