StompClient implementation in k6

Hello!
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;

      self.doSearch();
    }, function (error) {
      console.log(error)
    });
  },

  doSearch: function () {

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

    this.stompClient.subscribe('/topic/results/' + sessionId, function (response) {
      self.handleResultsResponse(JSON.parse(response.body));
    });
    this.stompClient.subscribe('/topic/metadata/' + sessionId, function (response) {
      self.handleMetadataResponse(JSON.parse(response.body));
    });
    this.stompClient.subscribe('/topic/snippets/' + sessionId, function (response) {
      self.handleSnippetsResponse(JSON.parse(response.body));
    });
    this.stompClient.subscribe('/topic/activities/' + sessionId, function (response) {
      self.handleActivitiesResponse(JSON.parse(response.body));
    });
  },    

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?

Thanks

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.

Regards,

Ivan

2 Likes