© Binildas Christudas 2019
Binildas ChristudasPractical Microservices Architectural Patternshttps://doi.org/10.1007/978-1-4842-4501-9_24

Apache TCPMon

Binildas Christudas1 
(1)
Trivandrum, Kerala, India
 

Apache TCPMon is a utility that allows traffic, especially HTTP traffic messages, to be viewed and resent. It is useful as a debug tool so you can look into what is being passed through the wire between a client and a server, or for that matter even between two microservices. It was originally part of Axis1 and now stands as an independent project. Go to https://ws.apache.org/tcpmon/ for more information.

I cover the following in this appendix:
  • How to install and start TCPMon

  • How to set up TCPMon as a proxy

Install TCPMon

In this section, you will download, install, and configure TCPMon and test the installation. TCPMon is available for download at https://ws.apache.org/tcpmon/download.cgi .

Save the installation archive file to a suitable location on your hard disk first and then extract the archive to a location of your choice. Even though you may choose any location, like
C:\Program Files\tcpmon\
I explicitly avoid a location with a space in the path, like the space in Program Files. Hence in my Windows machine, I use the following location:
D:\Applns\apache\TCPMon\tcpmon-1.0-bin

Start Using TCPMon

You can bring up TCPMon by going into the build folder of the TCPMon extracted folder (shown in Figure E-1):
cd D:\Applns\apache\TCPMon\tcpmon-1.0-bin\build
D:\Applns\apache\TCPMon\tcpmon-1.0-bin\build>tcpmon
../images/477630_1_En_24_Chapter/477630_1_En_24_Fig1_HTML.jpg
Figure E-1

Bring up TCPMon

Set Up TCPMon as a Proxy

TCPMon can act as a proxy. To set TCPMon in proxy mode, just select the proxy option from the radio buttons and configure the host and port towards which the calls are to be proxied.

Alternatively, you can supply the configuration parameters when you start TCPMon itself. The usage pattern is
D:\Applns\apache\TCPMon\tcpmon-1.0-bin\build>tcpmon [listenPort targetHost targetPort]
You will get the screen shown in Figure E-2 if you start like
D:\Applns\apache\TCPMon\tcpmon-1.0-bin\build>tcpmon 8081 127.0.0.1 8080
D:\Applns\apache\TCPMon\tcpmon-1.0-bin\build>java -cp ./tcpmon-1.0.jar org.apache.ws.commons.tcpmon.TCPMon 8081 127.0.0.1 8080
../images/477630_1_En_24_Chapter/477630_1_En_24_Fig2_HTML.jpg
Figure E-2.

TCPMon configured as a proxy

All requests hitting port 8081 in the host where TCPMon is running will be proxied to port 8080 in host 127.0.0.1 in the above case.

Summary

TCPMon is a nice utility to inspect HTTP requests and responses. You can install and keep it ready on your machine so that it's easy for you to quickly proxy HTTP requests and responses through TCPMon and inspect the contents of the messages.