Pratyaksh Aggarwal
Pratyaksh Aggarwal

Reputation: 31

Non HTTP response code: java.net.UnknownHostException in JMeter

I am trying to do load testing using JMeter for the first time. I am trying to access URL : http://ss12345.localhost:9001/testManagement/login. The Sampler Result Printed as :

Thread Name:Thread Group 1-1
Sample Start:2020-04-02 18:25:52 IST
Load time:21
Connect Time:21
Latency:0
Size in bytes:2490
Sent bytes:0
Headers size in bytes:0
Body size in bytes:2490
Sample Count:1
Error Count:1
Data type ("text"|"bin"|""):text
Response code:Non HTTP response code: java.net.UnknownHostException
Response message:Non HTTP response message: ss12345.localhost


HTTPSampleResult fields:
ContentType: 
DataEncoding: null

I do not understand why it is not picking the userSpecificSubDomain : ss12345. If I do not specify userSpecificSubDomain then it opens the Login Page otherwise it throws the Non HTTP response code: java.net.UnknownHostException. For more details, refer to the below images.

Image 1

Image 2

Upvotes: 2

Views: 2998

Answers (1)

Dmitri T
Dmitri T

Reputation: 168247

JMeter tries to resolve the IP address of the DNS hostname ss12345.localhost and since it is not known it fails to determine the address therefore it fails.

If you have JMeter and the application under test on your local machine you can:

  1. Add the next line to the hosts file (normally lives under C:\Windows\System32\drivers\etc\hosts)

    127.0.0.1   ss12345.localhost
    
  2. Or alternatively (or if you don't have administrator permissions hence cannot edit the hosts file) you can add a DNS Cache Manager to your Test Plan and specify the mapping there:

    enter image description here


Just in case be aware that having the application under test and the load generator running on the same machine is not the best idea as they will start struggling for resources so load test results will not be reliable as you won't be able to tell whether it is a performance bottleneck or it just a lack of i.e. RAM

Upvotes: 3

Related Questions