0

I'm using the following code in Gatling:

.exec(ws("Open WS connection")
      .open("/${session_id}/socket?device=other"))
      .pause(2)
.exec(ws("Get client browser id")
      .sendText("[]")    
      .check(wsListen.within(10).until(1).jsonPath("$.[2]").saveAs("clientID")))

It does not report any failure. I assume it means that the JSON value was stored in the clientID variable successfully. When I add

.exec{
       session =>
        println("clientID: " + session("clientID").as[String])
        session
    }

I get error

[ERROR] i.g.c.a.b.SessionHookBuilder$$anon$1 - 'hook-1' crashed with 'java.util.NoSuchElementException: key not found: clientID', forwarding to the next one This call works in JMeter. Please help.

Vladimir
  • 630
  • 3
  • 12
  • 26

1 Answers1

0

I guess you have to reconciliate ws branch and main branch:

https://gatling.io/docs/2.3/http/websocket/#reconciliate

As stated in the ref doc:

As a consequence, main HTTP branch and a WebSocket branch can exist in a Gatling scenario in a dissociated way, in parallel. When doing so, each flow branch has it’s own state, so a user might have to reconcile them, for example when capturing data from a WebSocket check and wanting this data to be available to the HTTP branch.

rashtao
  • 657
  • 5
  • 16