0
votes

I have to load test a WebSocket on Jmeter. WebSocket has been implemented using Springboot. I am facing an issue while sending Stomp data on Jmeter while testing. I am framing text appropriately according to stomp frame. This is the CONNECT frame:

log.info("Connect PreProcessor");

String con = "CONNECT\n" +       
       "login:${wsToken}\n" +
                   "passcode:admin\n" +
                   "accept-version:1.1,1.0\n" +
                   "heart-beat:0,0\n" +  
                   "\n"+'\0' ;

vars.put("wsStompCon", con);    

I am making a send request and when I am subscribing to the connection, AMQ establishes a connection, and I get the CONNECTED response. So no issue in connection. The issue happens when I am sending data as:

String User = "SEND\n" +
                    "content-length:39\n" +
                    "destination:/app/chat.newUser\n\n" +
                    "{\"sender\": \"Usr111222\",\"type\":\"JOIN\"}" +
                    '\0' ;

vars.put("wsAddUser", User);

I put the var 'wsAddUser' in the send sampler and am sending the data.

I get this error in response sampler:

ERROR message: Frame must be terminated with a null octet content-length:0

I am using websocket plugin by Peter Doornbosch mentioned:

https://bitbucket.org/pjtr/jmeter-websocket-samplers/src/master/

I have changed the encoding to UTF-8 in Jmeter.Properties file as well. I think the issue is due to encoding but I'm not sure. What changes should I do for this issue?

1

1 Answers

0
votes
  1. It looks like your calculation of the content-length header is not very correct as {"sender": "Usr111222","type":"JOIN"} is 37 octets and \0 is another octet so it should be 38.
  2. It is not recommended to inline JMeter Functions or Variables into Groovy scripts so you need to replace this line:

    "login:${wsToken}\n" +
    

    with this one:

    "login:" + vars.get("wsToken") + "\n" +
    

    (as long as it's not a GStringTemplate)

    where vars stands for JMeterVariables class instance, see the JavaDoc for more information and Top 8 JMeter Java Classes You Should Be Using with Groovy for description of other JMeter API shortcuts available for the JSR223 Test Elements