"Long running" handlers

infectedrhytms infectedrhythms at hotmail.com
Fri Mar 5 12:09:09 EST 2010


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);
}






-- 
View this message in context: http://n2.nabble.com/Long-running-handlers-tp4677280p4682110.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list