June 9th, 2014

Connecting to Cassandra’s JMX service through firewalls can be tricky. JMX connects you through one port (7199 by default), and then opens up a dynamic port with the application. This makes remote JMX connections difficult to set up securely.


Fortunately, we can set up a SOCKS proxy connection using SSH.

The SOCKS proxy transmits TCP connections through the proxy server. This means that any request — HTTP or otherwise — is viewed as originating from the proxy server. It’s an effective way of bypassing the firewalls in place on a computer, as well as masking the origin of a request.

We can set up a connection with:

  • -D [bind_address:]port: Direct remote traffic to this port on the local machine.
  • -N: Set the connection up to be closeable by a Keyboard Interrupt.
  • -v: Use verbose mode to check on exactly what traffic is being transmitted.

Now we need to set our system to connect via the proxy. On OS X, open up ‘System Preferences > Network > Advanced > Proxies’, and enable the SOCKS proxy on localhost:9999.

Setting up the SOCKS proxy

Security: Now you are connected to the remote server, and all network traffic will be routed through the proxy. Make sure to turn off any other applications — your browser, background apps — that use the network.

Most applications are set to automatically use your system’s proxy, though you can manually set them to not use a proxy.


Start jconsole and add ‘localhost:7199’ as a remote entry.

The screen will automatically populate with a list of running Java programs.

Click through to the CassandraDaemon view. The first five tabs — Overview, Memory, Threads, Classes, VM Summary — show Java runtime statistics, while the last tab, MBeans, give access into the running application.

Setting up the SOCKS proxy

The Memory tab gives a purview into the health of the JVM. You can review the different memory pool generations, and heap and non-heap usage.

Threads and Classes both offer glimpses into their namesakes, while VM Summary gives a dated report on the state of the JVM. This is useful for collecting system overviews.

Finally, the MBeans tab offers tooling and insight into Cassandra.

You’re now connected to Cassandra, and can change the values while the process is running. Make sure to monitor the logs for any anomalies while updating the configuration.

JMX Management Over Socks Proxy” was written by Patricia Gorla, Cassandra MVP and Apache Cassandra architect at The Last Pickle.