Skip to main content

Recording using HTTP Proxy in Jmeter

Configuring a proxy in Jmeter:

The first step before recording a script let’s configure proxy in WorkBench.

WorkBench : The WorkBench simply provides a place to temporarily store test elements while not in use, for copy/paste purposes, or any other purpose you desire. When you save your test plan, WorkBench items are not saved with it. Your WorkBench can be saved independently, if you like.

The HTTP(S) proxy server (prior to Version 2.10) or HTTP(S) Test Script Recorder (Version 2.10 onwards) allows JMeter to intercept and record your actions while you browse your web application with your normal browser. JMeter will create test sample objects and store them directly into your test plan as you go.

The recorder is implemented as an HTTP(S) proxy server. You need to set up your browser use the proxy for all HTTP and HTTPS requests. [Do not use JMeter as the proxy for any other request types - FTP, etc. - as JMeter cannot handle them.]

Launch Jmeter.
To use the recorder, add the HTTP(S) Test Script Recorder element to the workbench. Select the WorkBench element in the tree, and right-click on this element to get the Add menu (Add --> Non-Test Elements --> HTTP Proxy or HTTP(S) Test Script Recorder). In newer versions HTTP Proxy Server is renamed as HTTP(S) Test Script Recorder.  This is as shown below in version 2.8:

In Version 2.10:

In this post we will follow with version 2.8.
Once the HTTP Proxy Server is added we have below fields:

Parameters for the above screen:
Descriptive name for this element that is shown in the tree.
The port that the HTTP Proxy listens to. 8080 is the default, but you can change it.
Target Controller
The controller where the proxy will store the generated samples. By default, it will look for a Recording Controller and store them there wherever it is.
Whether to group samplers for requests from a single "click" (requests received without significant time separation), and how to represent that grouping in the recording:
  • Do not group samplers: store all recorded samplers sequentially, without any grouping.
  • Add separators between groups: add a controller named "--------------" to create a visual separation between the groups. Otherwise the samplers are all stored sequentially.
  • Put each group in a new controller: create a new Simple Controller for each group, and store all samplers for that group in it.
  • Store 1st sampler of each group only: only the first request in each group will be recorded. The "Follow Redirects" and "Retrieve All Embedded Resources..." flags will be turned on in those samplers.
  • Put each group in a new transaction controller: create a new Transaction Controller for each group, and store all samplers for that group in it.
The property proxy.pause determines the minimum gap that JMeter needs between requests to treat them as separate "clicks". The default is 1000 (milliseconds) i.e. 1 second. If you are using grouping, please ensure that you leave the required gap between clicks.
Capture HTTP Headers
Should headers be added to the plan? If specified, a Header Manager will be added to each HTTP Sampler. The Proxy server always removes Cookie and Authorization headers from the generated Header Managers. By default it also removes If-Modified-Since and If-None-Match headers. These are used to determine if the browser cache items are up to date; when recording one normally wants to download all the content. To change which additional headers are removed, define the JMeter property proxy.headers.remove as a comma-separated list of headers.
Add Assertions
Add a blank assertion to each sampler?
Regex Matching
Use Regex Matching when replacing variables? If checked replacement will use word boundaries, ie it will only replace word matching values of variable, not part of a word. A word boundary follows Perl5 definition and is equivalent to \b.
Which type of sampler to generate (the Java default or HTTPClient)
Redirect Automatically
Set Redirect Automatically in the generated samplers?
Follow Redirects
Set Follow Redirects in the generated samplers?
Note: see "Recording and redirects" section below for important information.
Use Keep-Alive
Set Use Keep-Alive in the generated samplers?
Retrieve all Embedded Resources
Set Retrieve all Embedded Resources in the generated samplers?
Content Type filter
Filter the requests based on the content-type - e.g. "text/html [;charset=utf-8 ]". The fields are regular expressions which are checked to see if they are contained in the content-type. [Does not have to match the entire field]. The include filter is checked first, then the exclude filter. Samples which are filtered out will not be stored. Note: this filtering is applied to the content type of the response
Patterns to Include
Regular expressions that are matched against the full URL that is sampled. Allows filtering of requests that are recorded. All requests pass through, but only those that meet the requirements of the Include/Exclude fields are recorded . If both Include and Exclude are left empty, then everything is recorded (which can result in dozens of samples recorded for each page, as images, stylesheets, etc are recorded). If there is at least one entry in the Include field, then only requests that match one or more Include patterns are recorded .
Patterns to Exclude
Regular expressions that are matched against the URL that is sampled. Any requests that match one or more Exclude pattern are not recorded .
Start Button
Start the proxy server. JMeter writes the following message to the console once the proxy server has started up and is ready to take requests: "Proxy up and running!".
Stop Button
Stop the proxy server.
Restart Button
Stops and restarts the proxy server. This is useful when you change/add/delete an include/exclude filter expression.

Once the above required parameters are set. Click on Start.
Note: To record in the browser we need to set the same proxy settings in browser also as shown below:

Launch the application in the browser and  run the required scenario. Jmeter will capture the requests as shown below. We see there are lot of .gif files captured before the actual login request. We can exclude these from recording.

If we observe the HTTP Request of each, we get information like Implementation, then Method GET/POST.  Also the Parameters section shows the Parameters and values passed. For example, I have used credentials username as demo and password as demo. These are shown above.
This is how we can record using HTTP Proxy Server.
Ideally use private browsing mode when recording the session. This should ensure that the browser starts with no stored cookies, and prevents certain changes from being saved. For example, Firefox does not allow certificate overrides to be saved permanently.

Note 1: The most important thing to do is filter out all requests you aren't interested in. For instance, there's no point in recording image requests (JMeter can be instructed to download all images on a page). These will just clutter your test plan. Most likely, there is an extension all your files share, such as .jsp, .asp, .php, .html or the like. These you should "include" by entering ".*\.jsp" as an "Include Pattern". Alternatively, you can exclude images by entering ".*\.gif" as an "Exclude Pattern". Depending on your application, this may or may not be a better way to go. You may also have to exclude stylesheets, javascript files, and other included files. Test out your settings to verify you are recording what you want, and then erase and start fresh. The matching is case-sensitive.

Note 2 : If JMeter does not record any samples, check that the brower really is using the proxy. If the browser works OK even if JMeter is not running, then the browser cannot be using the proxy. Some browsers ignore proxy settings for localhost or; try using the local hostname or IP instead.

Note 3: The error "unknown_ca" probably means that you are trying to record HTTPS, and the browser has not accepted the JMeter Proxy server certificate.


  1. Note 2 really helped me debug my problem of not getting recorded. My set localhost to all proxies it worked!
    Thank you!

  2. Thank you, very explaining in detail. Keep up the good work.

  3. Hi, good explanation. Just want to give +1 on the hearts effect onclick. just made my day :)

  4. NIce article for Record and Playback feature in Jmeter.thanks for sharing...

  5. Very interesting and informative blog..thanks for sharing...
    multiple proxies


Post a Comment

Popular posts from this blog

Steps to Analyze AWR Report in Oracle

Steps to Analyze AWR Report in Oracle
AWR -Automaticworkload repository is a collection of persistentsystem performancestatisticsowned by SYS. It resides in SYSAUXtablespace. Bydefault snapshot are generated once every 60 min and maintained for 7 days. Each snapshot has a unique ID know as "snap_id". Snapshot detail can be found in "dba_hist_snapshot" view.
If we have Database performance issue and not the Database machine, then AWR Report is the place to look at. AWR is not used for real-time performance monitoring like the v$ tables. It is used for historical analysis of performance. AWR complements, but doesnot replace real-time monitoring.
Once AWR Report is generated in Oracle, the next task is to analyze it. By going through the AWR Report we can easily solve issues like slow database, high wait events, slow query and many more issues. Even though the report is lengthy, Analyzing or Reading relevant part of AWR Report can help to troubleshoot issues in easy and …

Recording Jmeter Scripts behind a proxy server

Recording Jmeter Scripts behind a proxy server
In one of the blog we saw the steps of recording Jmeter scripts using a proxy server.
JMeter has its own in-built Proxy Server, theHTTP(S) Test Script Recorder. This is only used for recording HTTP or HTTPS browser sessions as explained in below link.
The above steps will work properly if the internet connection is not behind a proxy and can be accessed directly.
If we are testing from behind a firewall/proxy server or if we the internet access is provided using proxy server then the above steps will fail and will not record any of the steps.
Steps to record in Jmeter if the internet is accessed via proxy:
1.Start Jmeter with the firewall/proxy server hostname and port number. To do so, Open a command prompt in windows and run the jmeter.bat file from a command line with the following parameters: -H [proxy server hostname or ip address]
-P [proxy s…