.await is not working without sendText for Websockets in Gatling 3.1.3

Hello,

With Gatling 2.3.1, I was able to wait till the appropriate message appears on WS channel without sending any message using sendText.

`

.exec(ws(“Checking Notification for event”).check(wsAwait.within(60 seconds).until(1).jsonPath("$").saveAs(“ccode”)))

.exec(session => {

val response = session(“ccode”).as[String]

println(s"Notification Response body: \n$response")

session

})

`

However, with 3.1.3, I guess sendText needs to send message and then wait. Below code throws error:

.exec(ws("Subscription Notification Message from Server").await(30 seconds) (ws.checkTextMessage("SubsNotif_Res_Body").check(jsonPath("$").saveAs("ccode")))) .exec(session => { val response = session("ccode").as[String] println(s"Notification Response body: \n$response") session })

Error:

09:18:07.638 [ERROR] i.g.c.ZincCompiler$ - /home/ubuntu/gatling-charts-highcharts-bundle-3.1.3/user-files/simulations/websocketexample/ws.scala:43:3: could not find implicit value for parameter ev: scala.concurrent.duration.DurationConversions.Classifier[io.gatling.http.check.ws.WsTextFrameCheck] (ws.checkTextMessage("SubsNotif_Res_Body").check(jsonPath("$").saveAs("ccode")))) ^ 09:18:07.683 [ERROR] i.g.c.ZincCompiler$ - one error found 09:18:07.685 [ERROR] i.g.c.ZincCompiler$ - Compilation crashed sbt.internal.inc.CompileFailed: null at sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:253) at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:122) at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:95) at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:91) at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23) at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:186) at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:82) at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3$adapted(MixedAnalyzingCompiler.scala:77) at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:215) at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:77) at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:146) at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:343) at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:343) at sbt.internal.inc.Incremental$.doCompile(Incremental.scala:120) at sbt.internal.inc.Incremental$.$anonfun$compile$4(Incremental.scala:100) at sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:180) at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:98) at sbt.internal.inc.Incremental$.$anonfun$compile$3(Incremental.scala:102) at sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:155) at sbt.internal.inc.Incremental$.compile(Incremental.scala:92) at sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:75) at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:348) at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:301) at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:168) at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:248) at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:74) at io.gatling.compiler.ZincCompiler$.doCompile(ZincCompiler.scala:210) at io.gatling.compiler.ZincCompiler$.delayedEndpoint$io$gatling$compiler$ZincCompiler$1(ZincCompiler.scala:215) at io.gatling.compiler.ZincCompiler$delayedInit$body.apply(ZincCompiler.scala:39) at scala.Function0.apply$mcV$sp(Function0.scala:39) at scala.Function0.apply$mcV$sp$(Function0.scala:39) at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17) at scala.App.$anonfun$main$1$adapted(App.scala:80) at scala.collection.immutable.List.foreach(List.scala:392) at scala.App.main(App.scala:80) at scala.App.main$(App.scala:78) at io.gatling.compiler.ZincCompiler$.main(ZincCompiler.scala:39) at io.gatling.compiler.ZincCompiler.main(ZincCompiler.scala)

Any help or leads there?!

As of Gatling 3, it’s currently not possible to wait for an incoming message without reacting to sending some message first, or opening the WebSocket.
Then, you can set wait for multiple incoming messages.

Stephane, thanks for the reply.
I am doing similar thing.

  1. Establishing WS connection
  2. Subscribing to a topic with sendText
  3. Parsing server response
  4. Wait until server sends a notification for the subscribed topic whenever an event occurs.
  5. Then parse that reply

Please find below the complete code:

`
import scala.concurrent.duration._

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._

class WebSockets extends Simulation {

val httpConf = http
.baseUrl("ws://x.x.x.x:8080/v2.0/api/name/dave/ws")
.header(“Someheader”, “Value”)
.wsBaseUrl(“ws://x.x.x.x:8080/v2.0/api/name/dave/ws”)

val scn = scenario(“Load TESTING”)
.exec(ws(“Connect WS”).connect("ws://x.x.x.x:8080/v2.0/api/name/dave/ws"))
.pause(1)
.exec(ws(“Send Notification Subscription”).sendText("""{
“type”: “PUT”,
“uri”: “/v1.0/api/name/dave/subscriptions”,
“body”: {
“subscriptions”: [
{
“resource_key”: “sales”
},
{
“resource_key”: “offers”
}
]
}
}""").await(10 seconds)
(ws.checkTextMessage(“Subs_Res_Body”).check(jsonPath("$").saveAs(“code”))))
.exec(session => {
val response = session(“code”).as[String]
println(s"Response body: \n$response")
session
})

//THIS PART WAITS FOR SERVER NOTIFICATION FOR AN EVENT TO OCCUR. UPON WHICH SERVER SENDS NOTIFICATION. NEED TO KNOW HOW THIS PART OF CODE SHOULD BE FORMED
.exec(ws(“Subscription Notification Message from Server”)
(ws.checkTextMessage(“SubsNotif_Res_Body”).check(await(60 seconds).until(1).jsonPath("$").saveAs(“ccode”))))
.exec(session => {
val response = session(“ccode”).as[String]
println(s"Notification Response body: \n$response")
session
})

.exec(ws(“Close WS”).close)

setUp(scn.inject(atOnceUsers(1))).protocols(httpConf)
}
`

Thanks in advance!

Stephane/others, any suggestions on this?

Can someone help me in how to wait for further responses from server after sending initial request and subscribing to the topic?

Any help there???