'Gatling Websocket react on message

Is it possible to write a gatling script which connects to WebSocket and then performs actions (e.g. new HTTP requests) when certain messages are received (preferably with out of the box support for STOMP messages, but I could probably workaround this).

In other words, "real clients" should be simulated as best as possible. The real clients (angular applications) would load data based on certain WebSocket messages.

I'm looking for something similar to (pseude code, does not work):

val scn = scenario("WebSocket")
  .exec(http("Home").get("/"))
  .pause(1)
  .exec(session => session.set("id", "Steph" + session.userId))
  .exec(http("Login").get("/room?username=${id}"))
  .pause(1)
  .exec(
    ws("Connect WS")
      .open("/room/chat?username=${id}")
      // ---------------------------------------------------------------------
      // Is it possible to trigger/exec something (http call, full scenario)
      // as reaction to a STOMP/WebSocket message?
      .onMessage(check(perform some check, maybe regex?).as("idFromPayload"))
      .exec(http("STOMP reaction").get("/entity/${idFromPayload}"))
      // ---------------------------------------------------------------------
  )
  .exec(ws("Close WS").close)
  // ideally, closing the websocket should only be done once the full scenario is over
  // (or never, until the script terminates in "forever" scenarios)

Is this currently possible? If not, is this planned for future versions of gatling?



Solution 1:[1]

To the best of my knowledge, this is not possible with Gatling.

I have since switched to k6 which supports writing and executing test scripts with this kind of logic/behavior.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 knittl