0
votes

When running JMeter in GUI mode, sometimes request stuck or takes a long (minute or more) time to get a response

Is there a way to view request before response received?

Obviously Listeners are executed after Sampler finish because of Scoping rules, but is there another way?

2

2 Answers

1
votes
  1. The simplest and the most obvious option is sending the request somewhere else, i.e. localhost, example.com, wherever. You will get response immediately therefore will be able to inspect the request details using View Results Tree listener
  2. A little bit more complicated option is printing the request details to jmeter.log file using JSR223 PreProcessor and Groovy which will query sampler instance which is a shorthand for HTTPSamplerProxy class like:

    log.info('URL: ' + (sampler.getUrl() as String) + sampler.getQueryString())
    log.info('Parameters: ')
    sampler.getArguments().each {arg -> 
        log.info(arg.getObjectValue() as String)
    } 
    if (sampler.getCookieManager() != null) {
        log.info('Cookies: ') 
        sampler.getCookieManager().getCookies().each { cookie ->
            log.info(cookie.getObjectValue() as String)
         }
    }
    
    if (sampler.getHeaderManager() != null) {
        log.info('Headers:')
        sampler.getHeaderManager().getHeaders().each {header -> 
            log.info(header.getObjectValue() as String)
        }
    }
    //etc
    

    Demo:

    enter image description here

0
votes

Following Master Apache JMeter book, filling the Timeouts can prevent such issues:

Fill the Timeouts (milliseconds) option of HTTP Request allows you not to wait for a SUT response indefinitely.

This will provide the following benefits :

• Allow JMeter to stop at the end of the test without waiting indefinitely for hanged requests. By default the timeout is infinite in HTTP Request