Using the HTTP Proxy in JMeter to record web interactions

I’ve been trying to figure out the performance of an application that runs over HTTP. Sounds like a perfect candidate for JMeter!

In the past, I’ve had to deal with native HTTPS applications which means I couldn’t use the HTTP Proxy to record sessions. However, since this application functions in both HTTP and HTTPS modes, this was my chance to understand and use the HTTP Proxy, so let’s go through how to set up and do this.

First, right click on the WorkBench and add the Non Test Element HTTP Proxy Server. Non Test Elements only appear when you right click on the WorkBench, so if you’ve never seen them before, now you know why.

Here are the options I recommend:

  • Port – I use 8000 just because I might be running an Application Server on port 8080. Any port over 1024 will see you right.
  • Target Controller – Select Use Recording Controller. We’ll add a Recording Controller just after this.
  • Grouping – I use Store 1st sampler of each group only just because I don’t want to save javascript or image files, just the HTML file being served. You may wish to pick a different option if you want to know the total amount of time to transfer all files to the end user for your performance test.
  • Capture HTTP Headers – I ticked it.
  • Add Assertions – I ticked it. Adds a blank assertion for each sampler. Since you’ll be using assertions later on to determine how requests are going, save time by adding a blank one now.
  • HTTP Sampler Type: HTTP Request HTTPClient. This is using the Apache HTTP Request library over the standard Java library.
  • Follow Redirects – I ticked it. This depends on the behaviour of your web application.
  • Redirect Automatically – I left blank. This also depends on the behaviour of your web application.

There are content filters you can add to stop sampling specific file types such as GIF and JPG, but since I just store the first sampler anyway, I normally leave these blank. Same with URL Pattersm to Exclude.

Right click on WorkBench and add Logic Controller > Recording Controller. All samplers recorded will be stored under here.

My useful tip – right click on the HTTP Proxy Server and add Listener > View Results Tree. This way you can analyse the requests being recorded by the HTTP Proxy.

Finally go back to the HTTP Proxy and click Start. All requests going through the HTTP Proxy on port 8000 are now being recorded.

Now head to your favourite web browser and set the HTTP proxy settings for localhost on port 8000. Anything you do now in that browser will be recorded by JMeter.

As you can see in the View Results Tree listener, you can see all the requests being made by the browser, such as:

  • the Sampler name
  • the Sampler result
  • the HTTP response code
  • Request information showing the actual request, and headers associated
  • And the actual response data, rendered as HTML

When you expand the Recording Controller, you’ll see the HTTP Request with the:

  • Server name
  • Protocol (HTTP, HTTPS)
  • Method (GET or POST)
  • Parameters (variables sent in the request)

All filled in for you. You’ll even see a HTTP Header Manager all filled in for you as well. Some web applications pay close attention to this, so it’s good to see all the information a normal browser sends.

So in summary, we’ve set up an HTTP Proxy to record sessions going through JMeter, and we’ve highlighted some of the options and what they do.

Leave a Reply

Your email address will not be published.