PORT allocation explanation?

"이희승 (Trustin Lee)" trustin at gmail.com
Mon May 2 07:42:48 EDT 2011


I had a chance to run the test you attached today.  According to lsof 
and netstat, I see no difference between the NIO and OIO transport.  Do 
you have an update since the last conversation?

Thanks for your patience

On Tue 04 Jan 2011 06:29:26 PM KST, Neil Avery wrote:
> Hi Trustin,
> Happy New Year to you as well!
> 
> Plain NIO - I havent tried (until now ;) ). I wouldnt expect ports to be
> opened which havent been asked for as it doubles port allocation, chews
> up machine resources etc so would be a fairly serious jdk bug... 
> 
> I ran the JDK/sample/nio/server then pointed a browser to make a couple
> of requests - could see the connection closed and the port enter
> TIMED_WAIT - etc. 
> 
> Using netstat you can see the jdk http server isnt allocating the same
> number of ports as NettyNIO:
> - NettyNIOServer PID is 6236
> - JDK/sample/nio/server PID is 6704
> 
> Netstat results:
> C:\work>netstat -o | grep 6236
>   TCP    127.0.0.1:49495 <http://127.0.0.1:49495>        envy14:49494  
>         ESTABLISHED     6236
>   TCP    127.0.0.1:49496 <http://127.0.0.1:49496>        envy14:49493  
>         ESTABLISHED     6236
>   TCP    127.0.0.1:49497 <http://127.0.0.1:49497>        envy14:49498  
>         ESTABLISHED     6236
>   TCP    127.0.0.1:49498 <http://127.0.0.1:49498>        envy14:49497  
>         ESTABLISHED     6236
> 
> C:\work>netstat -o | grep 6704
>   TCP    127.0.0.1:49461 <http://127.0.0.1:49461>        envy14:49462  
>         ESTABLISHED     6704
>   TCP    127.0.0.1:49462 <http://127.0.0.1:49462>        envy14:49461  
>         ESTABLISHED     6704
> 
> 
> Ive attached the test source from the original posting.
> 
> Cheers Neil.
> 
> On Tue, Jan 4, 2011 at 2:31 AM, Trustin Lee <trustin at gmail.com
> <mailto:trustin at gmail.com>> wrote:
> 
>     Hi Neil,
> 
>     (sorry about the delay and happy new year!)
> 
>     Netty does not open any port that is not requested by a user.  Do
>     you observe the same problem when you run similar test code using
>     plain NIO?
> 
>     --
>     Trustin Lee - http://gleamynode.net/
>     Sent from a mobile device - please excuse the brevity.
> 
>     On Jan 2, 2011, at 6:02 PM, Neil Avery <neil at liquidlabs.co.uk
>     <mailto:neil at liquidlabs.co.uk>> wrote:
> 
>     > Bump - trustin would u have any ideas?
>     >
>     > ---------- Forwarded message ----------
>     > From: Neil Avery <neil at liquidlabs.co.uk
>     <mailto:neil at liquidlabs.co.uk>>
>     > Date: Thursday, December 9, 2010
>     > Subject: PORT allocation explanation?
>     > To: Netty -Users List <netty-users at lists.jboss.org
>     <mailto:netty-users at lists.jboss.org>>
>     >
>     >
>     > Hi,We have been using Netty with great success. One of the things we
>     > have recently found that there seems to be a unexplainable number of
>     > ports being opened. Ive hijacked the Echo Client and Server - the test
>     > is below:
>     >    @Test    public void shouldFireUpServerAndRunClient() throws
>     Exception {
>     >
>     >        System.out.println("PID:" +
>     > ManagementFactory.getRuntimeMXBean().getName());      
>      EchoServer.main(new
>     > String[0]);
>     >                EchoClient.main(new String[] { "localhost",
>     "33333", "1024" });
>     >    }
>     > By the time the test is running and msgs pinging back and forth we
>     > observe 7 opened ports which have no explanation (see observations
>     > below). When swapping in OioServerSocketChannelFactory and
>     > OioClientSocketChannelFactory we end up with 3 ports (2 for the JVM)
>     > and 1 client-server connection.....which is what we would expect from
>     > the Nio factorys.... is there a reason for the ports being allocated
>     > or is it something that can be fixed in configuration?
>     >
>     > Platform: Windows 7, Java 1.6_20 x86, Netty 3.2.3 Final
>     > Regards Neil.
>     > Nio observervations:
>     > 1. Start the TestCase (break before running EchoServer and netstat
>     > shows the values below. I assume this is jconsole/jmx or something
>     > associated with the JVM management.
>     >
>     >   TCP    127.0.0.1:61013 <http://127.0.0.1:61013>      
>      envy14:61012           ESTABLISHED
>     > 10080  TCP    127.0.0.1:61014 <http://127.0.0.1:61014>      
>      envy14:61011
>     > ESTABLISHED     10080
>     >
>     >
>     > 2. Step over EchoServer so that its sitting there waiting (on port
>     > 33333): - 2 more ports are opened....  TCP    127.0.0.1:61013
>     <http://127.0.0.1:61013>
>     > envy14:61012           ESTABLISHED     10080
>     >   TCP    127.0.0.1:61014 <http://127.0.0.1:61014>      
>      envy14:61011           ESTABLISHED
>     > 10080  TCP    127.0.0.1:61016 <http://127.0.0.1:61016>      
>      envy14:61017
>     > ESTABLISHED     10080
>     >   TCP    127.0.0.1:61017 <http://127.0.0.1:61017>      
>      envy14:61016           ESTABLISHED     10080
>     > 3. Then let the EchoClient run and we observe the following....
>     >   TCP    127.0.0.1:33333 <http://127.0.0.1:33333>      
>      envy14:61018           ESTABLISHED
>     > 10080  TCP    127.0.0.1:61013 <http://127.0.0.1:61013>      
>      envy14:61012
>     > ESTABLISHED     10080
>     >   TCP    127.0.0.1:61014 <http://127.0.0.1:61014>      
>      envy14:61011           ESTABLISHED
>     > 10080  TCP    127.0.0.1:61016 <http://127.0.0.1:61016>      
>      envy14:61017
>     > ESTABLISHED     10080
>     >   TCP    127.0.0.1:61017 <http://127.0.0.1:61017>      
>      envy14:61016           ESTABLISHED
>     > 10080  TCP    127.0.0.1:61018 <http://127.0.0.1:61018>      
>      envy14:33333
>     > ESTABLISHED     10080
>     >   TCP    127.0.0.1:61021 <http://127.0.0.1:61021>      
>      envy14:61022           ESTABLISHED
>     > 10080  TCP    127.0.0.1:61022 <http://127.0.0.1:61022>      
>      envy14:61021
>     > ESTABLISHED     10080
>     >   TCP    127.0.0.1:61023 <http://127.0.0.1:61023>      
>      envy14:61024           ESTABLISHED
>     > 10080  TCP    127.0.0.1:61024 <http://127.0.0.1:61024>      
>      envy14:61023
>     > ESTABLISHED     10080
>     >
>     >
>     > The same test with Oio - port allocation is:  TCP  
>      127.0.0.1:33333 <http://127.0.0.1:33333>
>     >      envy14:61040           ESTABLISHED     3236
>     >   TCP    127.0.0.1:61039 <http://127.0.0.1:61039>      
>      envy14:61038           ESTABLISHED
>     > 3236  TCP    127.0.0.1:61040 <http://127.0.0.1:61040>      
>      envy14:33333           ESTABLISHED
>     >     3236
>     >
>     >
>     >
>     >
>     >
>     >
>     > --
>     >
>     > www.liquidlabs.co.uk <http://www.liquidlabs.co.uk>
>     >
>     > _______________________________________________
>     > netty-users mailing list
>     > netty-users at lists.jboss.org <mailto:netty-users at lists.jboss.org>
>     > https://lists.jboss.org/mailman/listinfo/netty-users
> 
>     _______________________________________________
>     netty-users mailing list
>     netty-users at lists.jboss.org <mailto:netty-users at lists.jboss.org>
>     https://lists.jboss.org/mailman/listinfo/netty-users
> 
> 
> 
> 
> -- 
> 
> www.liquidlabs.co.uk <http://www.liquidlabs.co.uk>
> 
> 
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users


More information about the netty-users mailing list