How Gatling can wait for x minutes after sending a websocket request

Hi Stéphane,
How Gatling can wait for X minutes after sending a Websocket request. I had tried to achieved by adding X times .await() but this is not the correct solution(highlighted below code). Please help.

protected def scorecardFanScenario2: ScenarioBuilder = scenario(“Scorecard websocket FanScenario”)
.exec(ws(“open socket”).connect("/listen").subprotocol(“graphql-ws”).header(“Sec-WebSocket-Protocol”, “graphql-ws”))
.exec(ws(“connection init”).sendText(connection_init)
.await(20)(ws.checkTextMessage(“connection_ack”).check(regex(".ack.").saveAs(“Message”)))
)
.exec(session => session{
println(session(“Message”).as[String])
session
})
.exec(ws(“Match Scorecard request”).sendText(matchCardScorePayload).await(400)(ws.checkTextMessage(“IN_PROGRESS”).check(regex(".IN_PROGRESS.").saveAs(“Message3”)))

.await(400)(ws.checkTextMessage(“IN_PROGRESS”).check(regex(".IN_PROGRESS.").saveAs(“Message3”)))
.await(400)(ws.checkTextMessage(“IN_PROGRESS”).check(regex(".IN_PROGRESS.").saveAs(“Message3”)))
.await(400)(ws.checkTextMessage(“IN_PROGRESS”).check(regex(".IN_PROGRESS.").saveAs(“Message3”)))
.await(400)(ws.checkTextMessage(“IN_PROGRESS”).check(regex(".IN_PROGRESS.").saveAs(“Message3”)))
.await(400)(ws.checkTextMessage(“IN_PROGRESS”).check(regex(".IN_PROGRESS.").saveAs(“Message3”)))
.await(400)(ws.checkTextMessage(“IN_PROGRESS”).check(regex(".IN_PROGRESS.").saveAs(“Message3”)))
.await(400)(ws.checkTextMessage(“IN_PROGRESS”).check(regex(".IN_PROGRESS.").saveAs(“Message3”)))
.await(400)(ws.checkTextMessage(“IN_PROGRESS”).check(regex(".IN_PROGRESS.").saveAs(“Message3”)))
.await(400)(ws.checkTextMessage(“IN_PROGRESS”).check(regex(".IN_PROGRESS.").saveAs(“Message3”)))
)
.exec(session => session{
println(session(“Message3”).as[String])
session
})

can I get any help here Gatling Devs/Users :slight_smile:

My use case is to receive N server response message in X minutes time after sending a single Websocket request

Hi Gatling team,

Can I expect a reply to my query?
If my problem is not clear please let me know.

Thanks
Prabhakar

I had tried to achieved by adding X times .await() but this is not the correct solution(highlighted below code)

Please elaborate on why this is not the correct solution.

Actually I don’t want to write the x times await statement inside the method to avoid the duplicate statement. I want the number of times await can be read from a configuration file and that many times the await statement can be executed when the script runs.

I am not able to put the await statement in the gatling loop in my above websocket scenario.

Thanks
Prabhakar

Hi Gatling team,

Have you understood my problem?
please help with sample code example if my problem is solvable in Gatling.

Thanks
Prabhakar

You’d have to use something like foldLeft but you’d need to know Scala.