Closing the Channel in first of a chain of Handlers
"이희승 (Trustin Lee)"
trustin at gmail.com
Fri Jan 14 22:15:37 EST 2011
Hi L,
You are seeing channelBound and channelConnected event because for an
accepted channel, an opened channel always means it's already bound and
connected. Therefore, closing an accepted channel also involves
disconnection and unbinding. Those events are basically purposed to be
semantically correct in terms of event model.
I think simplifying the event model might be a better idea than having 3
events per accepted channel. Good food for though for 4.0. :-)
HTH,
Trustin
On 01/14/2011 09:14 PM, lepe wrote:
>
> 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
--
Trustin Lee, http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 294 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20110115/1def3f02/attachment.bin
More information about the netty-users
mailing list