[mobicents-public] RTSP Client Implementation Problem

148 views
Skip to first unread message

Zelalem Sintayehu

unread,
Mar 9, 2010, 5:42:24 AM3/9/10
to mobicent...@googlegroups.com
Hi Amit let me rephrase my problem that I faced in implementing the rtsp client. I wanted to implement the rtsp client and used the rtspclientimpl code. But because there is no event handler for it (the one that i found - RtspController - i thought is for the server), i created another controller based on the RtspController (and called it RtspControllerClient). Basically I put some code in the onRtspResponse  method which checks if the response status (coming from teh server) is OK and then if it is OK it calls the appropriate class to process the response based on the LastRequest (i.e. I have a variable to hold  what the last request was and i used it to check if the last request was OPTION, for eg., and then I'll run the code to send the next request which is DESCRIBE in this case etc.)  I have also put some code to send the first message to the server in the Start method of the RtspControllerClient. Then, I created a "main class" to initiate the client but when I run it I got an error. The error is inside the sendRequest method of RtspClientImpl. The following is the error I got:

70 [New I/O client worker #1-1] INFO org.mobicents.media.server.
ctrl.rtsp.stack.RtspClientStackImpl  - And this is the second request
71 [New I/O client worker #1-1] ERROR org.mobicents.media.server.ctrl.rtsp.RtspController  - Unexpected error during processing,Caused by
java.lang.NullPointerException

        at org.mobicents.media.server.ctrl.rtsp.stack.RtspClientStackImpl.sendRquest(RtspClientStackImpl.java:135)
        at org.mobicents.media.server.ctrl.rtsp.RtspControllerClient.onRtspResponse(RtspControllerClient.java:171)
        at org.mobicents.media.server.ctrl.rtsp.stack.RtspClientStackImpl.processRtspResponse(RtspClientStackImpl.java:85)
        at org.mobicents.media.server.ctrl.rtsp.stack.RtspResponseHandler.messageReceived(RtspResponseHandler.java:28)
        at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:80)
        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
        at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302)
        at org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndfireMessageReceived(ReplayingDecoder.java:513)
        at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:497)
        at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:434)
        at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:80)
        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:540)
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)
        at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:353)
        at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:277)
        at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:197)
        at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
        at org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)

I trace the error and it happens at the following line:

                // Wait for the server to close the connection.
channel = future.awaitUninterruptibly().getChannel();

I think the "future = bootstrap.connect(new InetSocketAddress(host, port));" code in the "if statement" just before the above statement is not executed and "future" is null. As I understand it the condition doesn't incorporate the following case (channel !=null and channel.isConnected()). So, I put another if statement to avoid executing the above statement in order to avoid the error but again I got the following error:

java.lang.IllegalStateException: await*() in I/O thread causes a dead lock or sudden performance drop. Use addListener() instead or call await*() from a different thread.
        at org.jboss.netty.channel.DefaultChannelFuture.checkDeadLock(DefaultChannelFuture.java:283)
        at org.jboss.netty.channel.DefaultChannelFuture.awaitUninterruptibly(DefaultChannelFuture.java:195)
        at org.mobicents.media.server.ctrl.rtsp.stack.RtspClientStackImpl.sendRquest(RtspClientStackImpl.java:154)
        at org.mobicents.media.server.ctrl.rtsp.RtspControllerClient.onRtspResponse(RtspControllerClient.java:171)
        at org.mobicents.media.server.ctrl.rtsp.stack.RtspClientStackImpl.processRtspResponse(RtspClientStackImpl.java:85)
        at org.mobicents.media.server.ctrl.rtsp.stack.RtspResponseHandler.messageReceived(RtspResponseHandler.java:28)
        at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:80)
        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
        at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302)
        at org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndfireMessageReceived(ReplayingDecoder.java:513)
        at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:497)
        at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:434)
        at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:80)
        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
        at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:540)
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)
        at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:353)
        at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:277)
        at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:197)
        at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
        at org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)

So I want you to help me how I can solve this problem or the previous one. BTW, is it correct to use the onRtspResonse to handle the response that I get from the Server? (or shall I consider it as request and use onRtspRequest?) I have attached the modified parts of the client implementation (basically it is in the following three classes: RtspResponseHandler, RtspControllerClient and RtspClientStackIMpl).

Thank you.


RTSPClientCode
Reply all
Reply to author
Forward
0 new messages