how to keep listening on a websocket without sending anything?

46 views
Skip to first unread message

Q Ethen

unread,
Jun 14, 2018, 8:10:34 AM6/14/18
to Gatling User Group
my websocket is used for push message, but do not deal with anything received from client,
in this case ,how can i keep listening on it?

David Miller

unread,
Jun 14, 2018, 12:00:19 PM6/14/18
to Gatling User Group
I think that your Gatling script will "keep listening" after opening and until you close (or end the script).
So I think that everything between 
e.g. exec(ws("Connect WS").open("/room/chat?username=steph")) and until e.g. exec(ws("Close WS").closethen Gatling will be "listening".

What I am less clear on is whether Gatling actually pulls/takes messages from the server when only doing a listen, or whether you need to do a .check(wsListen.

Cheers,
Dave.

Ethen

unread,
Jun 14, 2018, 12:08:16 PM6/14/18
to Gatling User Group
yeh,same question,need  help ~

在 2018年6月15日星期五 UTC+8上午12:00:19,David Miller写道:

Ethen

unread,
Jun 14, 2018, 10:25:32 PM6/14/18
to Gatling User Group
hey,David
maybe it works  some time:
val listener = scenario("listener")
  .exec(
    ws("Connect WS")
      .wsName("someName")
      .open("/sb/?port=9543")
      .headers(socketHeaders)
  )
  .forever(
    exec(
      ws("Keep Listening").wsName("someName")
        .check(wsAwait.within(50000).until(1))
    )
  )

output like this ,is it means “keep listening” works?




but i got a new problem,when i add a jsonpath to check the message content send by server
val listener = scenario("listener")
  .exec(
    ws("Connect WS")
      .wsName("someName")
      .open("/sb/?port=9543")
      .headers(socketHeaders)
  )
  .forever(
    exec(
      ws("Keep Listening").wsName("someName")
        .check(wsAwait.within(50000).until(1)
          .jsonPath("$..error_code").exists
        )
    )
  )

no keep listening requests list in the output





在 2018年6月15日星期五 UTC+8上午12:00:19,David Miller写道:
I think that your Gatling script will "keep listening" after opening and until you close (or end the script).

Ethen

unread,
Jun 14, 2018, 10:45:03 PM6/14/18
to Gatling User Group
ahhhh....I am so silly, wait time too long
when i set it properly, the keep listening request  can be list in output.
i guess sse maybe deal with the same way , try it

David Miller

unread,
Jun 18, 2018, 12:42:45 PM6/18/18
to Gatling User Group
Hi Ethan,
Thanks for posting this info :)
Thanks,
Dave 
Reply all
Reply to author
Forward
0 new messages