Help with STOMP over WebSocket

Hello team,
I am new to Gatling and I am trying to run gatling test on simple stomp websocket application
below is my code
The test is failing at validation check every time.

import io.gatling.javaapi.core.ScenarioBuilder;
import io.gatling.javaapi.core.Simulation;
import io.gatling.javaapi.http.HttpProtocolBuilder;

import static io.gatling.javaapi.core.CoreDsl.*;
import static io.gatling.javaapi.http.HttpDsl.http;
import static io.gatling.javaapi.http.HttpDsl.ws;

public class StompTest extends Simulation {
    {

        HttpProtocolBuilder httpProtocol = http
                .baseUrl("http://localhost:8080")
                .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // Here are the common headers
                .doNotTrackHeader("1")
                .acceptLanguageHeader("en-US,en;q=0.5")
                .acceptEncodingHeader("gzip, deflate")
                .userAgentHeader("Gatling")
                .wsBaseUrl("ws://localhost:8080");
        String serverId = "10000001";
        String sessionId = "thisisnewsession1";
        String transport = "websocket";

        ScenarioBuilder scn = scenario("WebSocket Scenario")
                .exec(ws("open socket connection").connect("/gs-guide-websocket")
                       .await(10)
                        .on(ws.checkTextMessage("checkConnection")
                                .check(regex("CONNECTED"))))

                .exec(ws("subscribe")
                        .sendText("[\"SUBSCRIBE\\nid:sub-0\\ndestination:/topic/greetings\\n\\n\\u0000\"]"))

                .exec(ws("publish message")
                .sendText("[\"SEND\\ndestination:/app/hello\\ncontent-length:15\\n\\n{\\\"name\\\":\\\"Tom\\\"}\\u0000\"]")
                .await(10).on(ws.checkTextMessage("checkNotification").check(regex("MESSAGE\\\\ndestination:\\/topic\\/greetings\\\\ncontent-type:application\\/json;charset=UTF-8\\\\nsubscription:sub-0\\\\nmessage-id:[\\w\\d-]*\\\\ncontent-length:\\d*\\\\n\\\\n\\{\\\\\"content\\\\\":\\\\\"Hello, Tom!\\\\\"\\}\\\\u0000"))))

                .exec(ws("close socket connection").close());

        setUp(scn.injectOpen(atOnceUsers(1))).protocols(httpProtocol);
    }
}

Below are some of the logs from my run.

10:53:03.381 [gatling-1-2] DEBUG io.gatling.http.action.ws.fsm.WsFsm - Timeout 1911584468 triggered
10:53:03.381 [gatling-1-2] DEBUG io.gatling.http.action.ws.fsm.WsPerformingCheckState - Check timeout
10:53:03.381 [gatling-1-2] DEBUG io.gatling.http.action.ws.fsm.WsPerformingCheckState - Check timeout, failing it and performing next action

10:52:53.376 [gatling-1-2] DEBUG io.gatling.http.action.ws.fsm.WsIdleState - Send text frame publish message ["SEND\ndestination:/app/hello\ncontent-length:15\n\n{\"name\":\"Tom\"}\u0000"]
10:52:53.377 [gatling-1-2] DEBUG io.gatling.http.client.impl.WebSocketHandler - ctx.write msg=TextWebSocketFrame(data: UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf(ridx: 0, widx: 79, cap: 256))
10:52:53.379 [gatling-1-2] DEBUG io.gatling.http.action.ws.fsm.WsIdleState - Trigger check after sending text frame
10:52:53.380 [gatling-1-2] DEBUG io.gatling.http.action.ws.fsm.WsFsm - Timeout 1911584468 scheduled
10:53:03.381 [gatling-1-2] DEBUG io.gatling.http.action.ws.fsm.WsFsm - Timeout 1911584468 triggered
10:53:03.381 [gatling-1-2] DEBUG io.gatling.http.action.ws.fsm.WsPerformingCheckState - Check timeout
10:53:03.381 [gatling-1-2] DEBUG io.gatling.http.action.ws.fsm.WsPerformingCheckState - Check timeout, failing it and performing next action

I am using Gatling version 3.9.3.1
I am not sure what is going wrong here.
Can some one help me with this pls.

Thanks in advance

Hello,

I am using Gatling version 3.9.3.1

That’s not a Gatling version. That’s a Gatling gradle plugin one.

  • latest Gatling 3.9.5
  • latest Gatling gradle plugin 3.9.5.2

There’s no way to help you unless you provide a reproducer.

Hi @slandelle ,

Thanks very much for quick reply.
here is the code for sample web socket application.

Test code is in here

Please let me know if you need any other details from me .

If you enable TRACE logging on your server, you’ll see lots of [TRACE] o.s.m.s.s.StompDecoder - Incomplete frame, resetting input buffer....

The WebSocket messages you’re sending with Gatling’s WebSocket support are not valid STOMP frames.

I’m not familiar with STOMP so I can’t help with this, so you’ll have to check the specification for yourself: https://stomp.github.io/stomp-specification-1.2.html. Maybe some community member will the able to help.

Then, people from Gatling the company can help, but as a consulting contract.

Hi @slandelle
Thanks for the reply, let me enable the logs and make changes as suggested and come back to you.

Hi @slandelle
Thanks for your inputs.
after updating my websocket message I am able to subscribe and Send request to application but both the checks which I am doing after Connection and after publishing the message are failing.
here is my updated code.

{

        HttpProtocolBuilder httpProtocol = http
                .baseUrl("http://localhost:8080")
                .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // Here are the common headers
                .doNotTrackHeader("1")
                .acceptLanguageHeader("en-US,en;q=0.5")
                .acceptEncodingHeader("gzip, deflate")
                .userAgentHeader("Gatling")
                .wsBaseUrl("ws://localhost:8080");



              ScenarioBuilder scn = scenario("WebSocket Scenario")
                        .exec(ws("open socket connection").connect("/gs-guide-websocket")
                       .await(10)
                                 .on(ws.checkTextMessage("checkConnection").check(regex("Connected: CONNECTED\n" +
                                         "heart-beat:0,0\n" +
                                         "version:1.2\n" +
                                         "content-length:0"))))

                .exec(ws("subscribe")
                        .sendText("SUBSCRIBE\n" +
                                "id:sub-0\n" +
                                "destination:/topic/greetings\n" +
                                "\n" +
                                "\u0000"))


                .exec(ws("publish message")
                        .sendText("SEND\n" +
                                "destination:/app/hello\n" +
                                "\n" +
                                "{\"name\":\"Tom\"}\u0000")


                .await(10).on(ws.checkTextMessage("checkNotification")

                                .check(regex("MESSAGE\ndestination:/topic/greetings\ncontent-type:application/json\ncharset=UTF-8\nsubscription:sub-0\nmessage-id:f6170be3-e096-46d4-8f2c-aae53d339ac4\n\\{\"content\":\"Hello, Tom!\"\\}\0"))))
                                .pause(20)
                .exec(ws("close socket connection").close());

        setUp(scn.injectOpen(atOnceUsers(1))).protocols(httpProtocol);

    }

Any help is highly appreciated.
Many thanks in advance,

Sudha

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.