Skip to content

Commit

Permalink
Added few docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aragozin committed Sep 21, 2023
1 parent 3fc429f commit 840b7db
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Next version
next version
----

0.21 - 2023 Apr 19
----

- Added `--force-hostname` option to overriden endpoint hostname on RMI stub with JMX connection hostname (useful for NAT and containers)
Expand Down
39 changes: 36 additions & 3 deletions sjk-core/docs/MPRX.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
`mprx` command
==============

`mprx` command opens JMX port on target JVM (specified by PID) suitable for remote connections from normal JMX
based tools, such as JVisualVM or Java Mission Control.
`mprx` command opens JMX port on target JVM (specified by PID or socket address) suitable for remote
connections from normal JMX based tools, such as JVisualVM or Java Mission Control.

It could be also used to solve problem with improprly setup remote JMX end point using `--force-address` option.

SJK acts as proxy in this case and socket would be closed after termination of SJK process.

Usage
-----

> java -jar skj.jar --help mprx
> java -jar sjk.jar mprx --help
JMX proxy - expose target process' MBeans for remote access
Usage: mprx [options]
Options:
--commands
Default: false
--force-address
Override hostname:port for JMX RMI stub, default false
Default: false
--force-hostname
Override hostname for JMX RMI stub, default false
Default: false
--force-port
Override port for JMX RMI stub, default false
Default: false
--help
Expand All @@ -33,3 +44,25 @@ Usage
* -b
Bind address - HOST:PORT

Example of process side proxy
-----------------------------

You can run `mprx` command on the same host as target process. While JMX agent could be started in runtime using `jcmd` from JDK,
sometimes JMX remote connectivy requires overriding `java.rmi.server.hostname` JVM system propery which cannot be done without
restart.

With `mprx` you can run JMX end point as separate process with full control overconfiguration.

Example of client side proxy
----------------------------

Even if remote JMX port is open and exposed, JMX connetion from tools such as VisualVM and MissionControl may not pass through.
Issue, usually, is in JMX handshake providing unroutable network address for data connection. You can use `mxping` to verify that.

SJK has `--force-address` to solve that kind of issue. If you want to use other tools, e.g. VisualVM, you can proxy JMX though SJK.

> java -jar sjk.jar mprx -s server.local:7777 --force-address -b 127.0.0.1:7777

Assuming server.local:7777 is listening JMX connections, you can not point VisualVM to 127.0.0.1:7777 and access remote MBean tree.

This also can be usefull if you are using any kind of port forwarding for remote access.
63 changes: 63 additions & 0 deletions sjk-core/docs/MXPING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
`mxping` command
==============

`mxping` command can be used to troubleshoot JMX connectivity. It accepts eigther process PID
or JMX socket address. In both cases process is throughfully logged helping problem cause identification.

In case of remote connection in sophysticated network topology, connection address received from RMI registry
on first step of JMX handshake may be incrorrect. `--force-address` option would be useful here to ignore address
from RMI stub.

Usage
-----

> java -jar sjk.jar mxping --help
[MXPING] Verify JMX connection to target JVM
Usage: mxping [options]
Options:
--commands
Default: false
--force-address
Override hostname:port for JMX RMI stub, default false
Default: false
--force-hostname
Override hostname for JMX RMI stub, default false
Default: false
--force-port
Override port for JMX RMI stub, default false
Default: false
--help
Default: false
--password
Password for JMX authentication (only for socket connection)
-p, --pid
JVM process PID
-s, --socket
Socket address for JMX port (host:port)
--user
User for JMX authentication (only for socket connection)
-X, --verbose
Enable detailed diagnostics
Default: false

Output example
--------------

> java -jar sjk.jar mxping -s 127.0.0.1:34000
SJK is running on: OpenJDK 64-Bit Server VM 25.275-b01 (BellSoft)
Java home: C:\WarZone\WarPath\Java\jdk1.8.0_275+1_bellsoft_x64\jre
Try to connect via TLS
Establishing connection to 127.0.0.1:34000
Failed to connect using TLS: java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
Try to use plain socket
Establishing connection to 127.0.0.1:34000
Establishing connection to 192.168.100.1:34000
Remote VM: OpenJDK 64-Bit Server VM 25.275-b01 (BellSoft)

As you can see in the listing above actual connection, as a part of JMX handshake, is made to 192.168.100.1:34000.
That address is provided in RMI remote stub received during first step of JXM handshake.

If address provided by JXM host is not routeable `--force-address` option could solve connectivity issue.

0 comments on commit 840b7db

Please sign in to comment.