Hi Trustin,<div>Happy New Year to you as well!</div><div><br><div>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... </div>
<div><br></div><div>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. </div><div><br></div><div>Using netstat you can see the jdk http server isnt allocating the same number of ports as NettyNIO:</div>
<div>- NettyNIOServer PID is 6236</div><div>- JDK/sample/nio/server PID is 6704</div><div><br></div><div>Netstat results:</div><div><div>C:\work>netstat -o | grep 6236</div><div> TCP <a href="http://127.0.0.1:49495">127.0.0.1:49495</a> envy14:49494 ESTABLISHED 6236</div>
<div> TCP <a href="http://127.0.0.1:49496">127.0.0.1:49496</a> envy14:49493 ESTABLISHED 6236</div><div> TCP <a href="http://127.0.0.1:49497">127.0.0.1:49497</a> envy14:49498 ESTABLISHED 6236</div>
<div> TCP <a href="http://127.0.0.1:49498">127.0.0.1:49498</a> envy14:49497 ESTABLISHED 6236</div><div><br></div><div>C:\work>netstat -o | grep 6704</div><div> TCP <a href="http://127.0.0.1:49461">127.0.0.1:49461</a> envy14:49462 ESTABLISHED 6704</div>
<div> TCP <a href="http://127.0.0.1:49462">127.0.0.1:49462</a> envy14:49461 ESTABLISHED 6704</div></div><div><br></div><div><br></div><div>Ive attached the test source from the original posting.</div>
<div><br></div><div>Cheers Neil.<br><br><div class="gmail_quote">On Tue, Jan 4, 2011 at 2:31 AM, Trustin Lee <span dir="ltr"><<a href="mailto:trustin@gmail.com">trustin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Neil,<br>
<br>
(sorry about the delay and happy new year!)<br>
<br>
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?<br>
<br>
--<br>
Trustin Lee - <a href="http://gleamynode.net/" target="_blank">http://gleamynode.net/</a><br>
Sent from a mobile device - please excuse the brevity.<br>
<div><div></div><div class="h5"><br>
On Jan 2, 2011, at 6:02 PM, Neil Avery <<a href="mailto:neil@liquidlabs.co.uk">neil@liquidlabs.co.uk</a>> wrote:<br>
<br>
> Bump - trustin would u have any ideas?<br>
><br>
> ---------- Forwarded message ----------<br>
> From: Neil Avery <<a href="mailto:neil@liquidlabs.co.uk">neil@liquidlabs.co.uk</a>><br>
> Date: Thursday, December 9, 2010<br>
> Subject: PORT allocation explanation?<br>
> To: Netty -Users List <<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a>><br>
><br>
><br>
> Hi,We have been using Netty with great success. One of the things we<br>
> have recently found that there seems to be a unexplainable number of<br>
> ports being opened. Ive hijacked the Echo Client and Server - the test<br>
> is below:<br>
> @Test public void shouldFireUpServerAndRunClient() throws Exception {<br>
><br>
> System.out.println("PID:" +<br>
> ManagementFactory.getRuntimeMXBean().getName()); EchoServer.main(new<br>
> String[0]);<br>
> EchoClient.main(new String[] { "localhost", "33333", "1024" });<br>
> }<br>
> By the time the test is running and msgs pinging back and forth we<br>
> observe 7 opened ports which have no explanation (see observations<br>
> below). When swapping in OioServerSocketChannelFactory and<br>
> OioClientSocketChannelFactory we end up with 3 ports (2 for the JVM)<br>
> and 1 client-server connection.....which is what we would expect from<br>
> the Nio factorys.... is there a reason for the ports being allocated<br>
> or is it something that can be fixed in configuration?<br>
><br>
> Platform: Windows 7, Java 1.6_20 x86, Netty 3.2.3 Final<br>
> Regards Neil.<br>
> Nio observervations:<br>
> 1. Start the TestCase (break before running EchoServer and netstat<br>
> shows the values below. I assume this is jconsole/jmx or something<br>
> associated with the JVM management.<br>
><br>
> TCP <a href="http://127.0.0.1:61013" target="_blank">127.0.0.1:61013</a> envy14:61012 ESTABLISHED<br>
> 10080 TCP <a href="http://127.0.0.1:61014" target="_blank">127.0.0.1:61014</a> envy14:61011<br>
> ESTABLISHED 10080<br>
><br>
><br>
> 2. Step over EchoServer so that its sitting there waiting (on port<br>
> 33333): - 2 more ports are opened.... TCP <a href="http://127.0.0.1:61013" target="_blank">127.0.0.1:61013</a><br>
> envy14:61012 ESTABLISHED 10080<br>
> TCP <a href="http://127.0.0.1:61014" target="_blank">127.0.0.1:61014</a> envy14:61011 ESTABLISHED<br>
> 10080 TCP <a href="http://127.0.0.1:61016" target="_blank">127.0.0.1:61016</a> envy14:61017<br>
> ESTABLISHED 10080<br>
> TCP <a href="http://127.0.0.1:61017" target="_blank">127.0.0.1:61017</a> envy14:61016 ESTABLISHED 10080<br>
> 3. Then let the EchoClient run and we observe the following....<br>
> TCP <a href="http://127.0.0.1:33333" target="_blank">127.0.0.1:33333</a> envy14:61018 ESTABLISHED<br>
> 10080 TCP <a href="http://127.0.0.1:61013" target="_blank">127.0.0.1:61013</a> envy14:61012<br>
> ESTABLISHED 10080<br>
> TCP <a href="http://127.0.0.1:61014" target="_blank">127.0.0.1:61014</a> envy14:61011 ESTABLISHED<br>
> 10080 TCP <a href="http://127.0.0.1:61016" target="_blank">127.0.0.1:61016</a> envy14:61017<br>
> ESTABLISHED 10080<br>
> TCP <a href="http://127.0.0.1:61017" target="_blank">127.0.0.1:61017</a> envy14:61016 ESTABLISHED<br>
> 10080 TCP <a href="http://127.0.0.1:61018" target="_blank">127.0.0.1:61018</a> envy14:33333<br>
> ESTABLISHED 10080<br>
> TCP <a href="http://127.0.0.1:61021" target="_blank">127.0.0.1:61021</a> envy14:61022 ESTABLISHED<br>
> 10080 TCP <a href="http://127.0.0.1:61022" target="_blank">127.0.0.1:61022</a> envy14:61021<br>
> ESTABLISHED 10080<br>
> TCP <a href="http://127.0.0.1:61023" target="_blank">127.0.0.1:61023</a> envy14:61024 ESTABLISHED<br>
> 10080 TCP <a href="http://127.0.0.1:61024" target="_blank">127.0.0.1:61024</a> envy14:61023<br>
> ESTABLISHED 10080<br>
><br>
><br>
> The same test with Oio - port allocation is: TCP <a href="http://127.0.0.1:33333" target="_blank">127.0.0.1:33333</a><br>
> envy14:61040 ESTABLISHED 3236<br>
> TCP <a href="http://127.0.0.1:61039" target="_blank">127.0.0.1:61039</a> envy14:61038 ESTABLISHED<br>
> 3236 TCP <a href="http://127.0.0.1:61040" target="_blank">127.0.0.1:61040</a> envy14:33333 ESTABLISHED<br>
> 3236<br>
><br>
><br>
><br>
><br>
><br>
><br>
> --<br>
><br>
> <a href="http://www.liquidlabs.co.uk" target="_blank">www.liquidlabs.co.uk</a><br>
><br>
</div></div>> _______________________________________________<br>
> netty-users mailing list<br>
<div class="im">> <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
</div>> <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
<br>
_______________________________________________<br>
netty-users mailing list<br>
<div class="im"><a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
</div><a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><br><a href="http://www.liquidlabs.co.uk">www.liquidlabs.co.uk</a><br>
</div></div>