The Eclipse IDE has a built-in TCP/IP Monitor tool that allows programmers to intercept communications between client and server through TCP/IP or HTTP protocol in order to monitor, watch and analyze the requests and responses. This article provides the steps which help you to use the TCP/IP monitor for the purpose of monitoring HTTP communications between the client and the server on a localhost machine.

Basically, the TCP/IP monitor acts as a proxy between the client and the server so that it can capture the requests and responses. And the most important thing to remember when using this monitor is that it requires changing the server port at the client side to the port at which the monitor is listening. The following diagram depicts the concepts:

TCP IP Monitor principle

For example, suppose that we need to monitor the HTTP communications of a web application running on localhost (typically under a Tomcat instance inside Eclipse), which would be normally accessed via this URL:

http://localhost:8080/FileUploadSpringMVC

And the TCP/IP Monitor is listening on the port number 9898, therefore we have to replace the port 8080 by 9898 as follows:

http://localhost:9898/FileUploadSpringMVC

If the monitor is running on the port 9898, it will receive the requests and forward them to the destination server at the port configured (8080).

Now, let’s go through the steps in details. Suppose that we want to monitor a web application developed in the tutorial: Spring MVC File Upload Tutorial with Eclipse IDE. The application is deployed on Tomcat server which is listening on the port number 8080.

 

Set up a TCP/IP Monitor in Eclipse:

Open the TCP/IP Monitor settings by go to the menu Window > Preferences > TCP/IP Monitor:



Select TCP IP Monitor in Preferences

Click Add to create a new monitor. In the New Monitor dialog, enter the following information:

    • Local monitoring port: 9898
    • Host name: localhost
    • Port: 8080
    • Type: HTTPNew Monitor settings

Click OK to add the new monitor to the list. Select the monitor and then click Start:

Start TCP IP Monitor

When the Status changed to Started, click OK to close the Preferences dialog. Next, click Window > Show View > Other… > TCP/IP Monitor> OK to open up the TCP/IP Monitor view:

Show TCP IP Monitor View

The TCP/IP Monitor view is added to the workspace but there is no information because no communication happens:

Empty TCP IP Monitor view

Now, make sure that the FileUploadSpringMVC application is up and running; open an Internal Web Browser (or an external browser) and type the following URL:

http://localhost:9898/FileUploadSpringMVC

The monitor immediately displays the request and response information as shown in the following screenshot:

HTTP GET request and response in TCP IP Monitor

Now, go back to the browser and try to enter some information and upload two files:

Test FileUploadSpringMVC app

The monitor captures the POST request and HTML response immediately:

POST request and HTML response in TCP IP Monitor

That’s really useful if we want to analyze the raw request and response! In addition, the TCP/IP monitor allows us to modify and resend the request, as well as watch the request/response in different types and encodings. Let experience the monitor further yourself! 

To stop the monitor, go to the TCP/IP Monitor settings in the Preferences dialog (or right click inside the TCP/IP Monitor view and select Properties). Then select the monitor you want to stop, and click Stop:

Stop TCP IP Monitor

 

Remember to change the port in the URL back to the regular number (8080) when the monitor is stopped.

 

Monitor hosts other than localhost:

Is it possible to monitor the communications between the web browser and sites other then the localhost? Oh, certainly! Here’s an example of the settings that are used to monitor the site www.bing.com:

TCP IP Settings to monitor Bing

Now, go to the browser and type the URL as http://localhost:9898, you will see the Bing’s home page! The request and response are captured by the monitor as shown in the following screenshot:

Request and response of Bing site

 

Related Tutorials:

 

Other Eclipse Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.



Add comment

   


Comments 

#4Anonimo2022-05-04 05:41
Thank you! The best explication
Quote
#3Keifer2015-12-02 18:53
What version of eclipse are you using? I tried Mars and Neon and neither have the TCP/IP monitoring under debug/run
Quote
#2Ashish Desai2015-10-23 17:17
This is great. Thank you very much it saved my day.
Quote
#1Vinay2015-07-13 04:09
Is there a way to figure out the tcp/ip requests done out of my webserver?
Quote