"Long running" handlers

Virat Gohil virat.gohil at gmail.com
Fri Mar 5 22:34:48 EST 2010


On Fri, Mar 5, 2010 at 10:39 PM, infectedrhytms <infectedrhythms at hotmail.com
> wrote:

>
> Thanks! It seems to be working, but I still see an issue.
>
> I'm trying to implement a server with netty using a persistent connection.
> I.e: The client will connect once and send all of it's messages over that 1
> connection. So now back to square one. If I implement 1 client connection 1
> 1 request and close the socket with
> future.addListener(ChannelFutureListener.CLOSE); I get no problem.
>
> Here is the log of my C++ application connecting to my netty server...
>
>
> Client opens 1 connection sends 5 messages... Server takes about 500ms to
> process each request...
>
> [15:38:26.215] Thread1, Send to netty id 1
> [15:38:26.215] Thread1, Send to netty finished
> [15:38:26.215] Thread2, Send to netty id 2
> [15:38:26.215] Thread2, Send to netty finished
> [15:38:26.215] Thread3, Send to netty id 3
> [15:38:26.215] Thread3, Send to netty finished
> [15:38:26.215] Thread4, Send to netty id 4
> [15:38:26.215] Thread4, Send to netty finished
> [15:38:26.215] Thread5, Send to netty id 5
> [15:38:26.215] Thread5, Send to netty finished
> [15:38:26.715] Thread1, Received head length from bank: Length=211 (d3)
> [15:38:26.731] Response incoming...
> [15:38:26.731] Response is for id 1
> [15:38:27.231] Response incoming...
> [15:38:27.231] Response is for id 2
> [15:38:27.731] Response incoming...
> [15:38:27.731] Response is for id 3
> [15:38:28.231] Response incoming...
> [15:38:28.231] Response is for id 4
> [15:38:28.731] Response incoming...
> [15:38:28.731] Response is for id 5...
>
> So as you can see the 5 messages where all sent at the same time, but then
> each response came in 500ms after each other as if they where queued. If I
> implement 1 client connection  per 1 request and close the connection in
> the
> handler everything is ok. But I need to keep the connection open.
>
> This is my handler implementation
>
> public class MyHandler extends SimpleChannelHandler {
>        String request = (String) e.getMessage();
>
> // Do some stuff here...
>
>        ChannelFuture future = e.getChannel().write(response);
>
>        // Do not close we need to keep 1 connection per client
>        //future.addListener(ChannelFutureListener.CLOSE);
> }
>
>
>From what you have described, it looks like your handler has some
synchronized methods, or using synchronized methods while processing the
requests. It would be best to turn on a profiler on the server and observe
the behavior.

Have Fun!

Virat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20100306/6bd2456a/attachment.html 


More information about the netty-users mailing list