No further action during custom HTTP polling

Hi,

I have a weird problem with a custom HTTP polling mechanism.
I wrote a function that polls periodically via HTTP and does so until the response contains a given RegEx. If this is the case, the extracted String is saved in the session. Otherwise the functions fails the current run.

I call the function with this:

`
.exec(poll(“Poll for ExecuteActionBtn”, Constants.ExecuteActionButton_RegEx, Constants.ExecuteActionButton_SaveString, 500, 10000))

`

This is the function:

`

  • Polls for a given RegExp and saves the result in the session as .
  • Fails the run if RegExp cannot be found in the given time.
    */
    def poll(stepName: String, regExpression: String, saveString: String, intervalMillis: Int, timeoutMillis: Int): ChainBuilder = {
    val maxTries: Double = timeoutMillis / intervalMillis
    logger.debug("MaxTries: " + maxTries)
    var i: Int = 0
    return asLongAs(session => { i < maxTries && !session.contains(saveString) }) {
    exec(http(stepName).get(POLLING_STRING)
    .check(regex(session => {
    i = i + 1
    logger.debug("Current Counter: " + i)
    logger.info("Poll: " + stepName)

regExpression
}).optional.saveAs(saveString), regex(Constants.ClientId_RegEx).saveAs(Constants.ClientId_SaveString)))
.pause(intervalMillis milliseconds)
}
//Fail polling (and the current run) if maxTries is exceeded.
.doIf(i >= maxTries)(exec(http(stepName).get(POLLING_STRING)
.check(regex(session => {
logger.error(stepName + " exceeded maxTries. Failing the run…")
“.”
}), status.is(-1))).exitHereIfFailed)
.exitHereIfFailed
}

`

As long as I need to poll less than 4 times, the function works as intended. The regExpression matches and the found value gets saved in the session as .
The problem occurs directly on the fourth polling attempt. Somehow it seems like the execution freezes and there is nothing happening. Gatling still prints the loadtest summary on the console every 5 seconds.

This is the end of the logfile:

`

08:47:07.584 [DEBUG] i.g.h.a.s.HttpTx$ - Sending request=Poll for ExecuteActionBtn uri=…: scenario=CreateCaseAndLogout, userId=1
08:47:07.606 [DEBUG] c.i.s.h.l.SimplePollingTest - Current Counter: 1.0
08:47:07.606 [INFO ] c.i.s.h.l.SimplePollingTest - Poll: Poll for ExecuteActionBtn
08:47:08.084 [DEBUG] i.g.h.a.s.HttpTx$ - Sending request=Poll for ExecuteActionBtn uri=…: scenario=CreateCaseAndLogout, userId=1
08:47:08.084 [DEBUG] c.i.s.h.l.SimplePollingTest - Current Counter: 2.0
08:47:08.084 [INFO ] c.i.s.h.l.SimplePollingTest - Poll: Poll for ExecuteActionBtn
08:47:08.584 [DEBUG] i.g.h.a.s.HttpTx$ - Sending request=Poll for ExecuteActionBtn uri=…: scenario=CreateCaseAndLogout, userId=1
08:47:08.584 [DEBUG] c.i.s.h.l.SimplePollingTest - Current Counter: 3.0
08:47:08.584 [INFO ] c.i.s.h.l.SimplePollingTest - Poll: Poll for ExecuteActionBtn
08:47:09.085 [DEBUG] i.g.h.a.s.HttpTx$ - Sending request=Poll for ExecuteActionBtn uri=…: scenario=CreateCaseAndLogout, userId=1

`

I tried to disable http caching, but this did not solve the problem.

Do you know by chance what I am missing?

Enable debug logging in AsyncHttpClient.
Most likely, the server closed the connection (or it timed out). We don’t support polling auto-reconnect yet: https://github.com/gatling/gatling/issues/3054