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