Hey Guys,
It’s mr. fairly new to websockets again.
Currently I’m trying to build a scenario where I connect to a websocket then listen to it for a while and then extract some data and work on from there on.
I’ve been looking at the documentation for websockets all day yesterday but I couldn’t figure out what would help me in this case.
When using ws.checkTextMessage after subscribing to a topic I’ve only been able to extract the confirmation message that the subscription was succesful.
Is there a feature I missed or am I expecting something that is more complicated to achieve then I thought.
I’ll add the scenario for some context.
When I use this specific regex I get an OK response however when I started looking for the other messages it fails.
Is there anyway to log everything that comes through the socket in gatling?
Thanks in advance.
//ws body variable
var WSBody = ""
def subscribeToTopic = scenario ("Subscribe to flights")
.exec(_.set("JWTtoken", JWTToken))
.exec(ws("Connect WS")
.connect(wsPath+"${JWTtoken}")
)
.pause(5)
exec(ws("subscribe to topic")
.sendText("""{"subscription":{"something":["something","completed"],"operation":null}}""")
.await(30 seconds)(
ws.checkTextMessage("checkMessages").check(regex(".*\"message\":\"subscription applied\".*").saveAs("wsResponse"))
))
.exec(session => {
WSBody = session("wsResponse").as[String].trim
println("%%%%%%%%%%% body =====>>>>>>>>>> " + WSBody)
session
}
)
.pause(60)
.exec(ws("Close WS")
.close
)