PORT allocation explanation?

Neil Avery neil at liquidlabs.co.uk
Tue Jan 4 04:29:26 EST 2011


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        envy14:49494           ESTABLISHED     6236
  TCP    127.0.0.1:49496        envy14:49493           ESTABLISHED     6236
  TCP    127.0.0.1:49497        envy14:49498           ESTABLISHED     6236
  TCP    127.0.0.1:49498        envy14:49497           ESTABLISHED     6236

C:\work>netstat -o | grep 6704
  TCP    127.0.0.1:49461        envy14:49462           ESTABLISHED     6704
  TCP    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> 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> wrote:
>
> > Bump - trustin would u have any ideas?
> >
> > ---------- Forwarded message ----------
> > From: Neil Avery <neil at liquidlabs.co.uk>
> > Date: Thursday, December 9, 2010
> > Subject: PORT allocation explanation?
> > To: Netty -Users List <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        envy14:61012           ESTABLISHED
> > 10080  TCP    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
> > envy14:61012           ESTABLISHED     10080
> >   TCP    127.0.0.1:61014        envy14:61011           ESTABLISHED
> > 10080  TCP    127.0.0.1:61016        envy14:61017
> > ESTABLISHED     10080
> >   TCP    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        envy14:61018           ESTABLISHED
> > 10080  TCP    127.0.0.1:61013        envy14:61012
> > ESTABLISHED     10080
> >   TCP    127.0.0.1:61014        envy14:61011           ESTABLISHED
> > 10080  TCP    127.0.0.1:61016        envy14:61017
> > ESTABLISHED     10080
> >   TCP    127.0.0.1:61017        envy14:61016           ESTABLISHED
> > 10080  TCP    127.0.0.1:61018        envy14:33333
> > ESTABLISHED     10080
> >   TCP    127.0.0.1:61021        envy14:61022           ESTABLISHED
> > 10080  TCP    127.0.0.1:61022        envy14:61021
> > ESTABLISHED     10080
> >   TCP    127.0.0.1:61023        envy14:61024           ESTABLISHED
> > 10080  TCP    127.0.0.1:61024        envy14:61023
> > ESTABLISHED     10080
> >
> >
> > The same test with Oio - port allocation is:  TCP    127.0.0.1:33333
> >      envy14:61040           ESTABLISHED     3236
> >   TCP    127.0.0.1:61039        envy14:61038           ESTABLISHED
> > 3236  TCP    127.0.0.1:61040        envy14:33333           ESTABLISHED
> >     3236
> >
> >
> >
> >
> >
> >
> > --
> >
> > www.liquidlabs.co.uk
> >
> > _______________________________________________
> > netty-users mailing list
> > netty-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/netty-users
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>



-- 

www.liquidlabs.co.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20110104/f4d76982/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NettyPortTest.rar
Type: application/rar
Size: 5472 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20110104/f4d76982/attachment-0001.bin 


More information about the netty-users mailing list