Está en la página 1de 10

11/22/2017 How to run JMeter behind the Proxy JMeter VN

JMeter VN

Discuss & Sharing about JMeter

ADVANCE, GENERAL, HOW TO

How to run JMeter behind the Proxy

Date: May 8, 2017 Author: harano1109 1 Comment


If your company use the proxy, so you might get some problem while working with
JMeter. The normal browser can access the website normally but JMeter. So why, and how
to x this, please read this post to nd out the answer.

0. Preparation

I created a Proxy Server on my local computer with

Host: localhost (127.0.0.1)


Port: 8888

https://jmetervn.com/2017/05/08/how-to-run-jmeter-behind-the-proxy/ 1/10
11/22/2017 How to run JMeter behind the Proxy JMeter VN

And I dont use the Username and Password for authentication.

Then I created a basic test plan like the image below, it consists of 1 HTTP Request
Defaults and 1 HTTP Request which will access to the site jmeter.apache.org

If I dont cong anything and run the Test Plan above, you will see the similar error like
this:

1 java.net.ConnectException: Connection refused (Connection refused)


2 at java.net.PlainSocketImpl.socketConnect(Native Method)
3 at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainS
4 at java.net.AbstractPlainSocketImpl.connectToAddress(Abstrac
5 at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSoc
6 at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392
7 at java.net.Socket.connect(Socket.java:589)
8 ...

Now, here we go. There are at least four ways to run JMeter behind the Proxy. Base on
what you need and what you want, to use the appropriate way.

1. Way 1

> Cong the Proxy Server into each HTTP Request.

In the HTTP Request, you can nd out the Proxy Server section in the bo om of HTTP
Request element, from version 3.2, youll nd it out in the Advance tab of HTTP Request.

Now, input the information of Proxy Server into this section. In my example, because Im
using the Proxy Server with Host localhost(127.0.0.1) , Port 8888 and dont use
username/password. So I will input this information like image below

https://jmetervn.com/2017/05/08/how-to-run-jmeter-behind-the-proxy/ 2/10
11/22/2017 How to run JMeter behind the Proxy JMeter VN

If the Proxy Server doesnt have the hostname like localhost and has IP only, so we
will input that IP into Server Name or IP eld.

NOTE: If your proxy required username/password, please input them into the
corresponding eld Username and Password.

Run the test again, everything should be ok now.

https://jmetervn.com/2017/05/08/how-to-run-jmeter-behind-the-proxy/ 3/10
11/22/2017 How to run JMeter behind the Proxy JMeter VN

2. Way 2

> Cong the Proxy Server into HTTP Request Defaults.

Imagine, if you have many requests, 100 requests for example, and youre using the way 1,
so you must input 100 times into those 100 requests, thats not a good idea, right? And in
case the Proxy Server is changed, you have to change in those 100 requests. So the idea is
to cong the Proxy Server into HTTP Request Default.

We will not input anything into the HTTP Requests, just open HTTP Request Defaults,
nd out the Proxy Server, and do the following:

Use the Proxy host and port

or use the Proxy IP and Port

NOTE: If your proxy required username/password, please input them into the
corresponding eld Username and Password.

Run the test again, everything should be ok now.

https://jmetervn.com/2017/05/08/how-to-run-jmeter-behind-the-proxy/ 4/10
11/22/2017 How to run JMeter behind the Proxy JMeter VN

3. Way 3

> Launch JMeter from the command line with the following parameters:

-H
[proxy server hostname or IP address]
-P
[proxy server port]
-N
[nonproxy hosts] (e.g. *.apache.org|localhost)
-u
[username for proxy authentication if required]
-a
[password for proxy authentication if required]

Example: Go to $JMETER_HOME/bin folder and run the command below

Windows:

jmeter -H localhost -P 8888

Or you can use the IP instead of Server name

jmeter -H 127.0.0.1 -P 8888

If your Proxy Server required username and password, use the command below

jmeter -H localhost -P 8888 -u username -a password

If a non-proxy host list is provided, use this command

jmeter -H localhost -P 8888 -u username -a password -N localhost

MAC:

./jmeter.sh -H localhost -P 8888

or

./jmeter.sh -H 127.0.0.1 -P 8888

or (if required username/password)


https://jmetervn.com/2017/05/08/how-to-run-jmeter-behind-the-proxy/ 5/10
11/22/2017 How to run JMeter behind the Proxy JMeter VN

./jmeter.sh -H localhost -P 8888 -u username -a password

or (if the non-proxy host is provided)

./jmeter.sh -H localhost -P 8888 -u username -a password -N localhost

NOTE: You can also use proxyHost, proxyPort, username, and password as
parameter names

Example:

jmeter --proxyHost localhost --proxyPort 8888

After launching by this way, you can check the Proxy Server in JMeter by:

Right click WorkBench, select Add > Non-Test Elements > Property Display

Check the checkbox System, and see the information related to Proxy, it should display
the information of the Proxy Server which we launched from the command line above

Now, the JMeter is running behind the proxy, and you can run the test plan without any
other conguration. It should run normally

P/S: You can use this way, to run the normal Test Plan with specic proxy

Example:

Window:
https://jmetervn.com/2017/05/08/how-to-run-jmeter-behind-the-proxy/ 6/10
11/22/2017 How to run JMeter behind the Proxy JMeter VN

jmeter -n -H localhost -P 8888 -t C:\jmeter\my-test-plan.jmx -l C:\jmeter

MAC:

./jmeter.sh -n -H localhost -P 8888 -t C:\jmeter\my-test-plan.jmx -l C:\j

4. Way 4

> Set the Proxy properties into the System properties le.

Open the system.properties in edit mode, this le is located under


/JMeter/bin/ directory
Add the following properties to the end of le

http.proxyHost
http.proxyPort
https.proxyHost
https.proxyPort

Example: I will cong the properties above into system.properties le with my Proxy
Server

http.proxyHost=localhost
http.proxyPort=8888
https.proxyHost=localhost
https.proxyPort=8888

If a non-proxy host list is provided, then JMeter sets the following System properties:

http.nonProxyHosts
https.nonProxyHosts

Example:

http.proxyHost=localhost
http.proxyPort=8888
https.proxyHost=localhost
https.proxyPort=8888
http.nonProxyHosts=example.com
https.nonProxyHosts=example.com

Open the JMeter, and try to check the System Properties as described in the way 3, you
should see the information like below:

https://jmetervn.com/2017/05/08/how-to-run-jmeter-behind-the-proxy/ 7/10
11/22/2017 How to run JMeter behind the Proxy JMeter VN

Now you can dene and run your test plan normally without any other conguration.

Advertisements

ADVANCE CONFIG JMETER

Published by harano1109

https://jmetervn.com/2017/05/08/how-to-run-jmeter-behind-the-proxy/ 8/10
11/22/2017 How to run JMeter behind the Proxy JMeter VN

View all posts by harano1109

One thought on How to run JMeter behind the Proxy

Add Comment

1. Pingback: List of All Posts JMeter VN

2017 JMETER VN

CREATE A FREE WEBSITE OR BLOG AT WORDPRESS.COM.

https://jmetervn.com/2017/05/08/how-to-run-jmeter-behind-the-proxy/ 9/10
11/22/2017 How to run JMeter behind the Proxy JMeter VN

https://jmetervn.com/2017/05/08/how-to-run-jmeter-behind-the-proxy/ 10/10

También podría gustarte