jmeter illegal character found in host: '/'

Viewed 2817

I'm trying to run jmeter to launch a load test.

One thing that I found strange is that I can run the following jmeter command in macOS without any problem.

PROTOCOL=https
DOMAIN=mywebsite.com/API
PORT=443
LOOP=1
THREADS=1

/var/jenkins_home/apache-jmeter-5.1.1/bin/jmeter \
  -Jjmeter.save.saveservice.output_format=xml \
  -Jprotocol=${PROTOCOL} \
  -Jdomain=${DOMAIN} \
  -Jport=${PORT} \
  -Jloop=${LOOP} \
  -Jthreads=${THREADS} \
  -n -t mywebsite.jmx \
  -l jmeter.jtl \
  -j mywebsite.log

But when I run the above command a linux machine, I got the error saying.

<httpSample t="0" it="0" lt="0" ct="0" ts="0" s="false" lb="" rc="Non HTTP response code: java.net.MalformedURLException" rm="Non HTTP response message: Illegal character found in host: &apos;/&apos;" tn="Thread Group 1-1" dt="text" by="822" sby="0" ng="1" na="1">
  <null/>
</httpSample>

And 100% of the jmeter requests failed.

This error message is found in jmeter.jtl result file.

It looks like that jmeter doesn't allow / in its domain in the linux environment. My domain mywebsite.com/API contains a / symbol.

The java version on my macOS is

java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)

and the java version on my linux machine is

java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

The jmeter on both of the systems is 5.1.1.

Does anyone know what goes wrong in my linux environment?

1 Answers

You cannot have / character as a part of server DNS hostname.

As per hostname documentation:

Each element of the hostname must be from 1 to 63 characters long and the entire hostname, including the dots, can be at most 253 characters long. Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, and the hyphen (-). A hostname may not start with a hyphen.

So you either need to split your DOMAIN property into:

HOSTNAME=mywebsite.com
PATH=/API

and use the properties in the HTTP Request sampler (or even better HTTP Request Defaults) like:

enter image description here

or alternatively leave "Server Name or IP" field blank and move your DOMAIN property to "Path" field like:

enter image description here

But in this case the configuration elements like HTTP Cookie Manager which rely on the hostname might not work properly

Related