PortUnificationServerHandler and Read/WriteTimeoutHandlers
fatzopilot
fatzopilot at gmx.net
Mon Oct 31 06:39:01 EDT 2011
Hi,
my project uses Netty for quite a while now with great success, kudos to the
Netty team and community!
The project is growing and needs a little bit of extension and now I've got
some questions...
So far it used a single protocol and all handlers were added in a single
PipelineFactory (in the getPipeline() method) upon pipeline creation.
Now, to support multiple protocol versions, I've changed the code to be
similar to the Port Unification example, i.e. there is a
PortUnificationServerHandler that detects the protocol and fills the
pipeline accordingly. However, using Read/WriteTimeoutHandlers seems to be
non-trivial in this scenario:
The server gets a lot of client connections that never send any message,
i.e. channelConnected is called but no data (not even a single byte) is sent
(I cannot influence this), so consequently, the decode() method is never
called. To get rid of stalled connections, the first thing that is added to
the pipeline (in the channelConnected() method of the
PortUnificationServerHandler) are Read/WriteTimeoutHandlers.
The first issue: They are never triggered unless a third dummy
SimpleChannelUpstreamHandler is added after them. I've read somewhere about
a similar issue (an extra handler needed to remain/to be added in order to
get a working pipeline) but cannot find this anymore. Is there a good
explanation why this is needed or can it yet be avoided?
The second issue remains unsolved so far: As described, the
Read/WriteTimeoutHandlers are added by PortUnificationServerHandler in the
channelConnected() method. When the timeout occurs, the ReadTimeoutHandler
throws an Exception. In the single protocol version, some handler's
exceptionCaught() method was called and the timeout could be handled gently.
In the multiple protocol version, this breaks, i.e. although
PortUnificationServerHandler.exceptionCaught() is implemented (this handler
added the ReadTimeoutHandler in the channelConnected() method), it is never
called and an org.jboss.netty.handler.timeout.ReadTimeoutException is thrown
instead:
Of course, in theory, this could be catched and handled directly but is does
seem to be a very dirty approach to me (the PortUnificationServerHandler is
removed from the pipeline later once a proper connection is established and
the protocol detected). So, any idea what is wrong here?
Thanks a lot
fatzopilot
--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/PortUnificationServerHandler-and-Read-WriteTimeoutHandlers-tp6947674p6947674.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list