Gatling Websocket implementation for subscribing to particular topic

Hello everyone,

Is there any way to subscribe to topic using Gatling websocket implementation? for example, below is the code in java script -

function connect() {
var socket = new SockJS(‘http://localhost:8090/gs-guide-websocket’);
stompClient = Stomp.over(socket);
stompClient.connect({}, function (frame) {
setConnected(true);
console.log(‘Connected: ’ + frame);
stompClient.subscribe(’/topic/3d36d506-f0bf-4756-aa27-57add9ea7ebf’, function (greeting) {
showGreeting(greeting.body);
});
});
}

would like to make similar in Gatling.

Thanks,
Vrushalee

You just need to send subscribe frame text to the websocket.
Text sent should look like smth like this:
val subscribeText = “[“SUBSCRIBE\nid:sub-1\ndestination:/topic/3d36d506-f0bf-4756-aa27-57add9ea7ebf\n\n\u0000”]”

Basically, to deal with STOMP protocol over websocket in Gatling, you’ll have to implement messages wrapping into proper STOMP frames yourself.
Don’t forget to send CONNECT frame before subscribing to anything, sending other messages etc.

Hi Katerina,

I was able to subscribe to particular topic with your help. I am again stuck with one problem. My case study is below -

1.Websocket Simulation is written which will connect and subscribe to particular topic.
2. Another simulation is written where I am sending few http requests. Once these request are sent, I received 202 status code which means it is in the processing queue of websocket. Once These requests are successful, I received particular frame/message on websocket simulation.

How can I make sure that all frames/message are received on websocket for which requests are sent from second simulation. Basically, I am looking for communication between these two script to verify results.

Thanks,
Vrushalee