StompClient implementation in k6

I have developer’s websocket client written with Stomp and SockJS. And I need to create a performance tests for this websocket connection. But I’m facing some questions. Here is developers code:
this.stompClient = Stomp.over(new SockJS(‘https://some-address/search’));

    this.stompClient.connect(headers, function (frame) {
      console.log('Connected: ' + frame);
      self.isConnected = true;

    }, function (error) {

  doSearch: function () {

    this.stompClient.send('/app/search', {}, JSON.stringify(request));

    this.stompClient.subscribe('/topic/results/' + sessionId, function (response) {
    this.stompClient.subscribe('/topic/metadata/' + sessionId, function (response) {
    this.stompClient.subscribe('/topic/snippets/' + sessionId, function (response) {
    this.stompClient.subscribe('/topic/activities/' + sessionId, function (response) {

As you can see, first connection is established here. But URL is not starting with “ws”, this gives me first error in k6.

Then there is a sending of 1 message and then a subscription to 4 topics. Each topic then returns some messages that I want to receive and to handle.
I just wonder how can I implement this logic in k6 syntax?

  1. Establish connection to http url
  2. Send message to “/app/search”
  3. Subscribe for 4 topics
  4. Handle their responses

Or maybe I can somehow import Stomp and SockJS to be used in k6?


1 Like

Hi there,

unfortunately, your use case is too complex for what k6 can currently handle.

While k6 aims to provide a fairly capable JavaScript environment, it’s not fully compatible with the way NodeJS or browsers interpret JavaScript. One of the biggest issues is lack of event loop and async support; see issue #882 for details. Even once this is added, compatibility with custom protocols like STOMP will likely need further development, though once async is supported it might be straightforward to connect with a SockJS client.

You’re welcome to keep following k6 development as there are some very interesting ideas planned for the near future, but right now STOMP/SockJS are not supported, sorry.




Hello @AlexJioev,
were you able to implement the tests for STOMP and SockJS eventually?

I have a similar task. There is a k6 extension for the support of STOMP protocol client. However, I’m still getting errors when trying to establish the connection.

Any feedback would be greatly appreciated.