[Red5] Responder onFail invocation

Yohann Martineau yohann.martineau at gmail.com
Wed Mar 4 04:43:37 PST 2009


It may seem obvious, but there seems to be two Responder classes in
flex: one in flash.net and the other one in mx.rpc. Did you check that
you're using the appropriated one?

in action script, you can catch exceptions with the following code:

try {
  // your code
} catch (error:Error) {
  // do whatever you want
  trace(error);
}

On 3/4/09, Stijn Janssens <red5 at zerotreize.com> wrote:
> Hi,
>
> I'm still struggling with something fairly basic...
>
> I try to invoke an operation on a Java Red5 service using AMF3
> remoting as follows:
>
> conn.call("test.testException", new Responder(onSuccess, onFail));
> function onSuccess(obj:Object):void{
> 	trace("Success: " + obj);
> }
> function onFail(obj:Object):void{
> 	trace("Fail: " + obj);
> }
>
> When the operation 'testException' executes normally, the onSuccess
> method is invoked (as expected).
> However, when the operation 'testException' encounters a problem and
> throws an exception (any exception Runtime or Checked), no Responder
> method is invoked and the following error is logged in the red5 log:
>
> ERROR o.r.server.service.ServiceInvoker - Service invocation error
> java.lang.reflect.InvocationTargetException
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke
> (NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke
> (DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at org.red5.server.service.ServiceInvoker.invoke(ServiceInvoker.java:
> 201)
> 	at org.red5.server.service.ServiceInvoker.invoke(ServiceInvoker.java:
> 119)
> 	at org.red5.server.net.rtmp.RTMPHandler.invokeCall(RTMPHandler.java:
> 158)
> 	at org.red5.server.net.rtmp.RTMPHandler.onInvoke(RTMPHandler.java:410)
> 	at org.red5.server.net.rtmp.BaseRTMPHandler.messageReceived
> (BaseRTMPHandler.java:146)
> 	at org.red5.server.net.rtmp.RTMPMinaIoHandler.messageReceived
> (RTMPMinaIoHandler.java:126)
> 	at org.apache.mina.common.support.AbstractIoFilterChain
> $TailFilter.messageReceived(AbstractIoFilterChain.java:570)
> 	at
> org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageRece
> ived(AbstractIoFilterChain.java:299)
> 	at org.apache.mina.common.support.AbstractIoFilterChain.access$1100
> (AbstractIoFilterChain.java:53)
> 	at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl
> $1.messageReceived(AbstractIoFilterChain.java:648)
> 	at org.apache.mina.filter.executor.ExecutorFilter.processEvent
> (ExecutorFilter.java:220)
> 	at org.apache.mina.filter.executor.ExecutorFilter
> $ProcessEventsRunnable.run(ExecutorFilter.java:264)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask
> (ThreadPoolExecutor.java:885)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run
> (ThreadPoolExecutor.java:907)
> 	at java.lang.Thread.run(Thread.java:619)
> Caused by: java.io.IOException: TEST EXCEPTION
> 	at vt.nvod.handler.impl.Red5ApplicationService.testException(Unknown
> Source)
> 	... 19 common frames omitted
> 2009-03-04 10:53:09,970 [pool-4-thread-11] ERROR
> o.r.s.n.r.codec.RTMPProtocolEncoder - Error encoding object:
> java.lang.NullPointerException
> 	at org.red5.io.object.Serializer.serializeField(Serializer.java:317)
> 	at org.red5.io.amf3.Output.writeObject(Output.java:483)
> 	at org.red5.io.object.Serializer.writeObjectType(Serializer.java:274)
> 	at org.red5.io.object.Serializer.writeComplex(Serializer.java:134)
> 	at org.red5.io.object.Serializer.serialize(Serializer.java:88)
> 	at org.red5.io.object.Serializer.serialize(Serializer.java:61)
> 	at
> org.red5.server.net.rtmp.codec.RTMPProtocolEncoder.encodeNotifyOrInvoke(
> RTMPProtocolEncoder.java:554)
> 	at
> org.red5.server.net.rtmp.codec.RTMPProtocolEncoder.encodeNotifyOrInvoke(
> RTMPProtocolEncoder.java:499)
> 	at org.red5.server.net.rtmp.codec.RTMPProtocolEncoder.encodeInvoke
> (RTMPProtocolEncoder.java:487)
> 	at org.red5.server.net.rtmp.codec.RTMPProtocolEncoder.encodeMessage
> (RTMPProtocolEncoder.java:277)
> 	at org.red5.server.net.rtmp.codec.RTMPProtocolEncoder.encodePacket
> (RTMPProtocolEncoder.java:118)
> 	at org.red5.server.net.rtmp.codec.RTMPProtocolEncoder.encode
> (RTMPProtocolEncoder.java:90)
> 	at org.red5.server.net.rtmp.codec.RTMPMinaProtocolEncoder.encode
> (RTMPMinaProtocolEncoder.java:46)
> 	at org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite
> (ProtocolCodecFilter.java:214)
> 	at
> org.apache.mina.common.support.AbstractIoFilterChain.callPreviousFilterW
> rite(AbstractIoFilterChain.java:361)
> 	at org.apache.mina.common.support.AbstractIoFilterChain.access$1300
> (AbstractIoFilterChain.java:53)
> 	at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl
> $1.filterWrite(AbstractIoFilterChain.java:659)
> 	at org.apache.mina.filter.executor.ExecutorFilter.filterWrite
> (ExecutorFilter.java:236)
> 	at
> org.apache.mina.common.support.AbstractIoFilterChain.callPreviousFilterW
> rite(AbstractIoFilterChain.java:361)
> 	at org.apache.mina.common.support.AbstractIoFilterChain.access$1300
> (AbstractIoFilterChain.java:53)
> 	at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl
> $1.filterWrite(AbstractIoFilterChain.java:659)
> 	at org.apache.mina.common.support.AbstractIoFilterChain
> $TailFilter.filterWrite(AbstractIoFilterChain.java:587)
> 	at
> org.apache.mina.common.support.AbstractIoFilterChain.callPreviousFilterW
> rite(AbstractIoFilterChain.java:361)
> 	at
> org.apache.mina.common.support.AbstractIoFilterChain.fireFilterWrite
> (AbstractIoFilterChain.java:355)
> 	at org.apache.mina.transport.socket.nio.SocketSessionImpl.write0
> (SocketSessionImpl.java:166)
> 	at org.apache.mina.common.support.BaseIoSession.write
> (BaseIoSession.java:177)
> 	at org.apache.mina.common.support.BaseIoSession.write
> (BaseIoSession.java:168)
> 	at org.red5.server.net.rtmp.RTMPMinaConnection.write
> (RTMPMinaConnection.java:193)
> 	at org.red5.server.net.rtmp.Channel.write(Channel.java:126)
> 	at org.red5.server.net.rtmp.Channel.write(Channel.java:103)
> 	at org.red5.server.net.rtmp.RTMPHandler.onInvoke(RTMPHandler.java:447)
> 	at org.red5.server.net.rtmp.BaseRTMPHandler.messageReceived
> (BaseRTMPHandler.java:146)
> 	at org.red5.server.net.rtmp.RTMPMinaIoHandler.messageReceived
> (RTMPMinaIoHandler.java:126)
> 	at org.apache.mina.common.support.AbstractIoFilterChain
> $TailFilter.messageReceived(AbstractIoFilterChain.java:570)
> 	at
> org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageRece
> ived(AbstractIoFilterChain.java:299)
> 	at org.apache.mina.common.support.AbstractIoFilterChain.access$1100
> (AbstractIoFilterChain.java:53)
> 	at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl
> $1.messageReceived(AbstractIoFilterChain.java:648)
> 	at org.apache.mina.filter.executor.ExecutorFilter.processEvent
> (ExecutorFilter.java:220)
> 	at org.apache.mina.filter.executor.ExecutorFilter
> $ProcessEventsRunnable.run(ExecutorFilter.java:264)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask
> (ThreadPoolExecutor.java:885)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run
> (ThreadPoolExecutor.java:907)
> 	at java.lang.Thread.run(Thread.java:619)
>
>
> This is a bit strange as the doc for Responder states:
> result:Function — The function invoked if the call to the server
> succeeds and returns a result.
> status:Function (default = null) — The function invoked if the server
> returns an error.
>
> I would have expected the onFail method to be executed...
>
> So my questions are:
> - why isn't the status function in the responder invoked?
> - is there a way to handle server-side exceptions on the client when
> using AMF3 remoting through Red5?
>
> I tried a solution suggested by Paul Mondain when I asked a similar
> question earlier:
> "You could catch the runtime exception in your Red5ApplicationService
> class and do a notify client call to pass an alert of some kind to
> your flash player."
> But the problem with this is that, although an alert is shown to the
> user, the onResult method is still invoked, which is not the expected
> behavior... Or how do you guys do exception handling on the client side?
>
> Thanks,
> Stijn
>
>
>



More information about the Red5 mailing list