I am upgrading to Gatling 3 and trying to make WebSockets work.
Here’s a simplified version of what I am trying to do:
`
class MySimulation extends Simulation {
private def operation1 =
exec(
ws(“operation1”)
.sendText("{}")
.await(1 minute) (
ws
.checkTextMessage(“Check response 1”)
.check(
jsonPath("$.var1")
.ofType[String]
.exists
.saveAs(“var1”) // Save var1 from operation 1
)
)
)
private def operation2 =
exec(
session => {
val var1 = session(“var1”).as[String]
exec(
ws(“operation1”)
.sendText(s"{var1:$var1}") // Use var1 from operation1 in operation2
)
session
}
)
private def scn =
scenario(“Scenario”)
.exec(
ws(“Connect socket”)
.connect(“wss://socketpath”) // Open connections
.onConnected(
exec(
pause(2 seconds),
operation1,
pause(2 seconds)
operation2,
pause(2 seconds),
ws(“Disconnect”) // Close connection
.close
)
)
)
setUp(
scn.inject(atOnceUsers(1))
).protocols(http)
}
`
I have subsequent socket operations that depend on each other (ie: the ID from one is needed in the other). In the simplified example, the issue is that the session doesn’t contain var1 after operation1.
What am I missing?
Thanks in advance.