WebSocket send message before test ending


I playing with GQL subscription and k6. Is there any way to send complete message at test completion?

Hi BratSinot, welcome to the forum!

While we don’t yet have per-VU setup or teardown, there are some workarounds available. There’s some good examples in this thread that can probably be adapted for your use case. If you get stuck, please post back here with what you’ve tried and we may be able to assist further.

Hi Tom! Thanks for answer!

From what I understood, only way is init all connections inside setup() and store to array?

That’s one of the approaches, yes. The other would be to use per-vu-iterations in options as per the second half of Ned’s post here. With that approach, you just need to be careful with the timeouts you set, which are subsequently used to determine appropriate startTime, duration, and maxDuration values (these combined are what allow you to run scenarios sequentially).

And where can I see default values?

Ok, I stored client into Array. But how I can get shutdown signal? teardown is called after VU shutdown.