JBoss EAP 6 opens random ports on Windows
Environment
- JBoss Enterprise Application Platform (EAP) 6.x
- Windows
Issue
- Using "netstat -aon" the set of ports that are being used by Jboss process in Windows. We recognized standard ports like 4447, 8080,9990,9999 etc, but unable to recognize the additional ports. Can you help us understand what these ports are used for?
- When running EAP 6 on Windows, the java process appears to open additional ports which seem to be random. What are these ports being used for?
Root Cause
The behaviour on Windows, which opens additional ports when compared to Linux which doesn't, is due to the implementation of the nio Selector.
The selector differs between platforms as well as JVM implementations (sun versus apple versus ibm for example)
Diagnostic Steps
- Download Byteman
- Download attached script
- Edit %JBOSS_HOME%/bin/standalone.conf.bat and add the byteman parameters
set "JAVA_OPTS=%JAVA_OPTS% -javaagent:%BYTEMAN_HOME/lib/byteman.jar=script:%BYTEMAN_HOME%/scripts/ports.btm,listener:true,boot:%BYTEMAN_HOME%/lib/byteman.jar -Dorg.jboss.byteman.transform.all"
- Start the JBoss instance in standalone mode
From the console output, 4 ports appear to have stacktraces similar to
*** server bind ServerSocket[addr=/127.0.0.1,localport=53432]sun.nio.ch.ServerSocketAdaptor.bind (Unknown Source)
sun.nio.ch.ServerSocketAdaptor.bind (Unknown Source)
sun.nio.ch.PipeImpl$Initializer.run (Unknown Source)
java.security.AccessController.doPrivileged (Unknown Source)
sun.nio.ch.PipeImpl.<init> (Unknown Source)
sun.nio.ch.SelectorProviderImpl.openPipe (Unknown Source)
java.nio.channels.Pipe.open (Unknown Source)
sun.nio.ch.WindowsSelectorImpl.<init> (Unknown Source)
sun.nio.ch.WindowsSelectorProvider.openSelector (Unknown Source)
java.nio.channels.Selector.open (Unknown Source)
org.xnio.nio.NioXnioWorker.<init>(NioXnioWorker.java:112)
org.xnio.nio.NioXnio.createWorker(NioXnio.java:126)
org.jboss.remoting3.EndpointImpl.construct(EndpointImpl.java:137)
org.jboss.remoting3.Remoting.createEndpoint(Remoting.java:60)
org.jboss.remoting3.Remoting.createEndpoint(Remoting.java:73)
and one with stacktrace similar to
*** server bind ServerSocket[addr=/127.0.0.1,localport=53436]sun.nio.ch.ServerSocketAdaptor.bind (Unknown Source)
sun.nio.ch.ServerSocketAdaptor.bind (Unknown Source)
sun.nio.ch.PipeImpl$Initializer.run (Unknown Source)
java.security.AccessController.doPrivileged (Unknown Source)
sun.nio.ch.PipeImpl.<init> (Unknown Source)
sun.nio.ch.SelectorProviderImpl.openPipe (Unknown Source)
java.nio.channels.Pipe.open (Unknown Source)
sun.nio.ch.WindowsSelectorImpl.<init> (Unknown Source)
sun.nio.ch.WindowsSelectorProvider.openSelector (Unknown Source)
java.nio.channels.Selector.open (Unknown Source)
org.jboss.sun.net.httpserver.ServerImpl.<init>(ServerImpl.java:147)
org.jboss.sun.net.httpserver.HttpServerImpl.<init>(HttpServerImpl.java:54)
org.jboss.sun.net.httpserver.DefaultHttpServerProvider.createHttpServer(DefaultHttpServerProvider.java:38)
org.jboss.com.sun.net.httpserver.HttpServer.create(HttpServer.java:147)
org.jboss.as.domain.http.server.ManagementHttpServer.create(ManagementHttpServer.java:150)
- Run the command
netsta -aon
On Windows the JBoss process opens 10 additional ports. These ports represent the two sides of each connection i.e the client and sever-side and are used by the remoting endpoints and the httpserver
Attachments
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
