Closing the Channel in first of a chain of Handlers
lepe
lennart.petersson at redpill-linpro.com
Fri Jan 14 07:14:28 EST 2011
Hi!
Just started testing Netty.
Laborating with the TimeServer tutorial. Have now a pipeline with three
handlers (WhitelistHandler (own), LoggingFilter (Netty), TimeServerHandler
(own)).
WhitelistHandler have channelOpen() among others implemented and if remote
address is not among a specified list of allowed addresses, channel.close()
are called.
Now, that works fine and the channel is closed as can be seen from following
logging:
1 [New I/O server boss #1 ([id: 0x5b7ee8b8, /127.0.0.1:2011])] WARN
WhiteListHandler - remote address not in whitelist, closing channel
2011-jan-14 13:05:11 org.jboss.netty.handler.logging.LoggingHandler
INFO: [id: 0x17386918, /127.0.0.1:54005 => /127.0.0.1:2011] CLOSE
2011-jan-14 13:05:11 org.jboss.netty.handler.logging.LoggingHandler
INFO: [id: 0x17386918, /127.0.0.1:54005 :> /127.0.0.1:2011] DISCONNECTED
2011-jan-14 13:05:11 org.jboss.netty.handler.logging.LoggingHandler
INFO: [id: 0x17386918, /127.0.0.1:54005 :> /127.0.0.1:2011] UNBOUND
2011-jan-14 13:05:11 org.jboss.netty.handler.logging.LoggingHandler
INFO: [id: 0x17386918, /127.0.0.1:54005 :> /127.0.0.1:2011] CLOSED
But then, to my surprise, I can see that I also gets the BOUND and CONNECTED
events in the pipeline:
429 [New I/O server boss #1 ([id: 0x5b7ee8b8, /127.0.0.1:2011])] DEBUG
WhiteListHandler - event is BOUND:/127.0.0.1:2011 but channel state is
closed
430 [New I/O server boss #1 ([id: 0x5b7ee8b8, /127.0.0.1:2011])] DEBUG
WhiteListHandler - event is CONNECTED:/127.0.0.1:54005 but channel state is
closed
Well... maybe not that surprised - I mean after OPENED I guess BOUND and
CONNECTED events was just lying there waiting for me to take care of :)
Now, in my first implementation this lead to WhitelistHandler to call
channel.close() again for the BOUND event and also for the CONNECTED event.
No problems for me to check whether the channel is open or closed first, but
I'm just curious if there are any way to close the channel and shout DON'T
BRING ME ANYMORE SHIT ON THIS CHANNEL BECAUSE I'M NOT INTERESED ANY LONGER
if you know what I mean :)
Else Netty is looking fine. Started with Mina last week and thought that was
the way to go before I started to google around on Mina vs. Netty ;)
regards,
/L
--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Closing-the-Channel-in-first-of-a-chain-of-Handlers-tp5921483p5921483.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list