GATLING - Subscribe checks for multiple messages real-time WebSocket

Hi friends,
I’am using Galting 3.2 and in the web socket stress test I use the subcribe method to test the correct read real -time notifications (stress test for In memory broker):

The part of code is:

val answerEventCheck = ws.checkTextMessage("<<RECEIVER Notification received")

.exec(ws("<<RECEIVER - SUBSCRIBE")
.await(seconds seconds)(answerEventCheck)

This ‘subscribe execution’ exits (unless in a cycle) when the websocket checks the correct single message (regex pattern). How can I count or read exactly the N notifications arrived for the user that I had opened the socket (with the same regex)?
Before the version 3.2 there was a websocket listener but for this version it’s not present. It is possible to count the N notifications received.

Any suggest?


hi Sebastiano,

I’m answering this question for the sake of future readers, although you might have already found a solution for your problem.

I did not use gatling 3.2, but with the current implementation (3.5.1) if you provide multiple checks, each one is going to be checked on one message, with the rest being applied to consecutive messages. so if you want to check n messages, provide n checks:
def await(timeout: FiniteDuration)(checks: WsTextFrameCheck*)

Hope this helps

Hi guys,

I’m also interested in such a solution, I want to get latency between messages. I’ve found such a solution put N check with the same Name, so then these checks will be on the same column in the report.

class Websocket extends Simulation {
val httpProtocol: HttpProtocolBuilder = http.baseUrl(“”)

val scene = scenario(“WS”)


I want to create a function that allows adding N checks to sendText. I tried to put an object which returned from sendText to session and then calls function repeat where I retrieve that object from the session and add the check, but I got “type mismatch” error.

type mismatch;
found : Unit
required: io.gatling.commons.validation.Validation[io.gatling.core.session.Session]
exec(session=> println(session(“ws-send-awaiter”).as[String]))

val scene = scenario(“WS”)
.onConnected(exec(session => session.set(“ws-send-awaiter”, ws(“Topic”)
.repeat(10,“i”) {
exec(session=> session(“ws-send-awaiter”).as[].await(10)(ws.checkTextMessage(“result”)))

среда, 17 марта 2021 г. в 11:12:37 UTC+2,