# How to receive messages in websockets client

**URL:** <https://community.gatling.io/t/how-to-receive-messages-in-websockets-client/1128>\
**Category:** Gatling (Open-Source)\
**Created:** [July 1, 2014, 11:24pm UTC](https://community.gatling.io/t/how-to-receive-messages-in-websockets-client/1128 "2014-07-01T23:24:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Lichtenberg](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@Tom\_Lichtenberg](https://community.gatling.io/u/Tom_Lichtenberg)\
**Post date:** [July 1, 2014, 11:24pm UTC](https://community.gatling.io/t/how-to-receive-messages-in-websockets-client/1128/1 "2014-07-01T23:24:19Z")

</div>

Is there an example of how to handle receiving a message from the websockets server using the gatling websockets plugin ([https://github.com/gilt/gatling-websocket](https://github.com/gilt/gatling-websocket)). The “complete” example shows:  
open  
sendMessage  
close

but what can be done in the case when the client is expecting one or more responses?

Thank you

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [July 2, 2014, 4:22am UTC](https://community.gatling.io/t/how-to-receive-messages-in-websockets-client/1128/2 "2014-07-02T04:22:11Z")

</div>

This plugin is a third party that Andrew/Gilt contributed to Gatling 2.  
It has been almost completely rebuilt since, and it ships with current snapshots:  
[https://github.com/excilys/gatling/wiki/Continuous-Integration](https://github.com/excilys/gatling/wiki/Continuous-Integration)

[https://github.com/excilys/gatling/blob/master/src/sphinx/http/websocket.rst](https://github.com/excilys/gatling/blob/master/src/sphinx/http/websocket.rst)

---

<div class="post-metadata">

**Author:** ![Tom\_Lichtenberg](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@Tom\_Lichtenberg](https://community.gatling.io/u/Tom_Lichtenberg)\
**Post date:** [July 2, 2014, 4:10pm UTC](https://community.gatling.io/t/how-to-receive-messages-in-websockets-client/1128/3 "2014-07-02T16:10:27Z")

</div>

Fantastic. And it’s working wonderfully -  
thanks very much

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [July 2, 2014, 4:16pm UTC](https://community.gatling.io/t/how-to-receive-messages-in-websockets-client/1128/4 "2014-07-02T16:16:42Z")

</div>

Glad to hear!  
You’re one of the first users of this new feature, so feel free to tell what you think about it (features, design, etc).

---

<div class="post-metadata">

**Author:** ![Tom\_Lichtenberg](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@Tom\_Lichtenberg](https://community.gatling.io/u/Tom_Lichtenberg)\
**Post date:** [July 2, 2014, 4:44pm UTC](https://community.gatling.io/t/how-to-receive-messages-in-websockets-client/1128/5 "2014-07-02T16:44:26Z")

</div>

I will. I have an immediate need for this, where the websocket server will be expected to send a certain number of responses within a certain period of time, and this implementation provides for exactly that check.

One thing, though - a separate issue - but using the snapshot build from July 1, 2014, my test runs are not producing any stats.tsv output files. Everything else seems ok.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [July 2, 2014, 5:21pm UTC](https://community.gatling.io/t/how-to-receive-messages-in-websockets-client/1128/6 "2014-07-02T17:21:19Z")

</div>

We ditched stats.tsv as the format was not convenient for the stats we export, and we also export a stats.json.

---

<div class="post-metadata">

**Author:** ![Tom\_Lichtenberg](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@Tom\_Lichtenberg](https://community.gatling.io/u/Tom_Lichtenberg)\
**Post date:** [July 2, 2014, 5:29pm UTC](https://community.gatling.io/t/how-to-receive-messages-in-websockets-client/1128/7 "2014-07-02T17:29:29Z")

</div>

json sounds fine, but I’m not seeing that either, only html files, the simulation.log, and the style and js folders in results. Is the json file supposed to be output by default?

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [July 2, 2014, 6:08pm UTC](https://community.gatling.io/t/how-to-receive-messages-in-websockets-client/1128/8 "2014-07-02T18:08:12Z")

</div>

The exact name is global\_stats.json and it’s supposed to be in the js directory.

---

<div class="post-metadata">

**Author:** ![Tom\_Lichtenberg](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@Tom\_Lichtenberg](https://community.gatling.io/u/Tom_Lichtenberg)\
**Post date:** [July 2, 2014, 7:43pm UTC](https://community.gatling.io/t/how-to-receive-messages-in-websockets-client/1128/9 "2014-07-02T19:43:02Z")

</div>

ok. found it. definitely an improvement  
thanks!

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [July 2, 2014, 8:56pm UTC](https://community.gatling.io/t/how-to-receive-messages-in-websockets-client/1128/10 "2014-07-02T20:56:56Z")

</div>

You’re welcome.  
Have fun!
