9 Replies Latest reply on Jul 12, 2007 6:04 AM by Mete Atamel

    my-amf pinging endpoint

    Cato Paus
      Hi all, I have an app. that uses remoteObjects, I'm building some logic for the remoteObject handler, and I'm testing the app. right now and the app is running, and I kill the JRun, and there is the issue, I want to catch the ('my-amf' pinging endpoint) or is it some other way to do the checking for JRun server are running ?
        • 1. Re: my-amf pinging endpoint
          Mete Atamel Level 1
          I'm not sure what you're asking if you are asking how you'd know when the server is down, you could listen for fault events and eventually when the client cannot contact the server, you'll get a fault event.
          • 2. Re: my-amf pinging endpoint
            Cato Paus Level 1
            Hi :)
            this is wath I do with the RO
            /**

            public function loginUser(user:String, pass:String):void {
            flexComRO = new RemoteObject();
            flexComRO.destination = "FlexComRO";
            flexComRO.LoginUser.addEventListener(ResultEvent.RESULT, loginUserResultHandler);
            flexComRO.LoginUser.addEventListener(FaultEvent.FAULT, faultHandler);
            CursorManager.setBusyCursor();
            flexComRO.LoginUser(user,pass);

            }
            **/

            If i have the Flex app running in my browser, and hit the loginUser function, with the JRun disconected. It hangs on the 'my-amf' pinging endpoint. where sould I put the event listener if I should catch the event ? Or do I have to create a my own timeout ?
            • 3. Re: my-amf pinging endpoint
              Mete Atamel Level 1
              Why are you doing this?

              flexComRO.LoginUser.addEventListener(ResultEvent.RESULT, loginUserResultHandler);
              flexComRO.LoginUser.addEventListener(FaultEvent.FAULT, faultHandler);

              I think you need the following instead:

              flexComRO.addEventListener(ResultEvent.RESULT, loginUserResultHandler);
              flexComRO.addEventListener(FaultEvent.FAULT, faultHandler);

              And when the JRun server is down, you should see a fault event in your "faultHandler" method (that I assume is already defined).
              • 4. Re: my-amf pinging endpoint
                Cato Paus Level 1
                Hi. I have some changes.

                /** code snipp

                public function loginUser(user:String, pass:String):void {
                flexComRO = new RemoteObject();
                flexComRO.destination = "FlexComRO";
                flexComRO.LoginUser.addEventListener(ResultEvent.RESULT, loginUserResultHandler);
                flexComRO.LoginUser.addEventListener(FaultEvent.FAULT, faultHandler);
                flexComRO.addEventListener(FaultEvent.FAULT, faultHandler);
                CursorManager.setBusyCursor();
                flexComRO.LoginUser(user,pass);

                }

                **/

                I'm doing it becouse I call many method's from Java.
                I have the flexComRO.addEventListener(FaultEvent.FAULT, faultHandler); to look for faults like server down -- this is the one that seems not to work..
                And I have flexComRO.LoginUser.addEventListener(FaultEvent.FAULT, faultHandler); to look for fault's in LoginUser method in Java

                • 5. Re: my-amf pinging endpoint
                  Level 7
                  Hi Cato,

                  You're syntax is fine and you can listen at the service level
                  (flexComRO) or the operation level (flexComRO.LoginUser).

                  What is happening under the covers is that the RemoteObject's underlying
                  Producer has ChannelSet. This ChannelSet loops through pinging each of
                  its Channels until one responds successfully. If you have more than one
                  channel defined for your RemoteObject destination it will move on to the
                  next before failing outright.

                  However, you may also be experiencing a bug where say if the Channel was
                  an AMFChannel, it's underlying flash.net.NetConnection may not be
                  throwing an error? Or perhaps the bug is that he AMFChannel is receivng
                  and error but not correctly dispatching the error?

                  You could try getting the channelSet off the RemoteObject instance and
                  adding an event listener for a "channelFault" type of event.

                  What version of FDS or LCDS are you using? Could you open the rpc.swc in
                  WinZip and look at catalog.xml and let us know what the version
                  information says?

                  Pete
                  • 6. Re: my-amf pinging endpoint
                    Cato Paus Level 1
                    Hi Pete

                    I'm using FDS 2.0.1

                    here is the info on rpc.swc file
                    <?xml version="1.0" encoding="utf-8" ?>
                    - <swc xmlns=" http://www.adobe.com/flash/swccatalog/9">
                    - <versions>
                    <swc version="1.0" />
                    <flex version="2.0.1" build="155493" />
                    </versions>

                    And I'm only using one channel for all the RemoteObjects.

                    do you have a sample code for me: "You could try getting the channelSet off the RemoteObject instance and
                    adding an event listener for a "channelFault" type of event."


                    Cato
                    • 7. Re: my-amf pinging endpoint
                      Level 7
                      There should be a channelSet propety on mx.rpc.remoting.RemoteObject. This
                      channelSet is an instance of mx.messaging.ChannelSet (and it should contain
                      an instance of mx.messaging.channels.AMFChannel).

                      import mx.messaging.ChannelSet;
                      import mx.messaging.events.ChannelFaultEvent;


                      ...

                      private function loginUser(user:String, pass:String):void
                      {
                      ...
                      var channelSet:ChannelSet = flexComRO.channelSet;
                      channelSet.addEventListener(ChannelFaultEvent.FAULT, handleChannelFault);
                      }

                      private function handleChannelFault(event:ChannelFaultEvent):void
                      {
                      trace(event.toString());
                      }



                      • 8. Re: my-amf pinging endpoint
                        Cato Paus Level 1
                        Hi if i try this it returns a error :

                        channelSet.addEventListener(ChannelFaultEvent.FAULT, handleChannelFault);
                        TypeError: Error #1009: Cannot access a property or method of a null object reference.
                        • 9. Re: my-amf pinging endpoint
                          Mete Atamel Level 1
                          The null pointer exception is because ChannelSet has not been initialized by the RemoteObject yet when you try to add a listener to it. One workaround is that you can manually create your own ChannelSet and assign it to the RemoteObject, and then add the listener to the ChannelSet. Something like:

                          var cs:ChannelSet = new ChannelSet();
                          cs.addChannel(new RTMPChannel(null, " http://localhost:2400"));
                          flexComRO.channelSet = cs;

                          I just used RTMPChannel with a random url as an example but you'll use whatever Channel you have with the right url.