TCPMon is a tool that can be used to view and monitor the messages passed along a TCP-based conversation. Therefore, this is a convenient tool, particularly useful for debugging when you develop Web services. TCPMon is an Apache project distributed under Apache 2.0 License. This tool is not dependent on any third party libraries. Its user interface is based on a swing UI and works on almost all platforms that support Java.
The most common usage of TCPMon is as an intermediary, which monitors the communication between the client (front end) and the back end server. That is, the messages sent from the client are received by the intermediary instead of the back end server.
TCPMon is available in the
<PRODUCT_HOME>/bin directory of any WSO2 Carbon based product distribution. Alternatively, you can download TCPMon from Apache and run the tool.
Running TCPMon (from Carbon product pack)
Ensure that the following prerequisites are fulfilled in order to run TCPMon.
- Install JDK 1.4 or later version.
JAVA_HOMEvariable. This setting is required only if you are using the TCPMon available in the WSO2 Carbon based product pack.
For information on how to set the
JAVA_HOMEvariable, go to Installing the Product, select the instructions relevant to your operating system and refer the 'Setting JAVA_HOME' section.
To run the TCPMon available with your WSO2 Carbon product pack:
- Go to
<AS_HOME>/bindirectory of your product pack.
Execute the following command to run the tool.
Running TCPMon (downloaded from Apache)
To download TCPMon from Apache and run the tool:
- Download TCPMon from the following location: http://archive.apache.org/dist/ws/tcpmon/1.0/tcpmon-1.0-bin.zip.
- Extract tcpmon-1.0-bin.zip archive.
- Go to the build of the extracted directory to find the execution script.
- Execute the following command to run the tool.
Monitoring Messages between Client and Server
The following diagram depicts a typical communication between the front end client and the back end server. 80 is the listening port of the back end server which receives the messages from the client
The following diagram depicts how TCPMon is placed between the client and the server in order to monitor the messages. 8081 is the listening port in TCPMon which receives the messages from the client instead of the back end server:
As an intermediary, TCPMon only receives messages and forwards them to the back end server. Therefore, it is a safe tool to be used for debugging purposes.
Note that TCPMon cannot be used to view messages transferred over https protocol.
To monitor messages from client to server using TCPMon:
- Start TCPMon. Follow the instructions on Starting TCPMon.
- Give 8081 (the listening port of TCPMon) in the Listen Port field (This could be any unused port in your local machine).
- Give the address of the back end server as the target hostname. For example, if you are monitoring messages sent to www.apache.org, enter this web address as the hostname.
- Give 80 as the target port, which is the listening port of www.apache.org.
- Click Add to save the setting.
- Now, point the browser to 'localhost:8081' instead of www.apache.org.
- A new tab in TCPMon will indicate the 8081 port. You can view the requests and responses passing through TCPMon as shown below.
The options at the bottom of the screen can be used to have the messages in XML format (useful in debugging Web services), to save and resend the messages and also to switch the layout of the message windows.