2 years ago

#13328

test-img

kjoxiphucy

Equivalent of Stomp.over in server side code

Is there a backend (nodejs, java, etc) equivalent of Stomp.over? I want to mimic the client side code like below:

var socket = null;
var stompClient = null;
var connectCallback = function() {
  console.log(stompClient.ws._transport.url); //get autogenerated url and session id here
}
var websocketConnect = function(){
  socket = new SockJS("/websocket");
  stompClient = Stomp.over(socket);
  stompClient.connect({}, connectCallback);
}
websocketConnect();
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/sockjs-client/1.4.0/sockjs.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js"></script>

This is to get the url returned by Stomp.over below, especially the generated sessionid:

wss://<base domain>/websocket/<sessionid>/

I want to use it for testing in k6, since it needs a wss url:

ws.connect(url, null, function (socket) {...}

The reason for this is I want to spawn different urls/sessions, mimicking different users opening their browsers and connecting to a base websocket url, then sending/receiving data to each using k6, thereby load testing it.

I have tried using node libraries such as stompjs and sockjs-client, but it differs in behavior, the object generated does not have an append a sessionid or similar, both just takes a full url in their constructor.

javascript

websocket

sockjs

k6

stompjs

0 Answers

Your Answer

Accepted video resources