The stomp client has a heartbeat function, and I’m going to write it as a test in gatling.
Looking at the gatling docs If I use during and pace together, I thought I could imitate the heart-beat.
What I want to send a message to the websocket every 5 seconds for a certain amount of time.
So I wrote the scenario as below.
scenario("subscribe topic from STOMP")
.feed(userFeeder.circular)
.exec(ws("connect websocket").connect(webSocketPath).onConnected(exec(tryStompConnect)))
.exitHereIfFailed
.exec(tryStompSubscribe(topic))
.during(duringTime) {
pace(5.second).exec(ws("send heart-beat").sendText(HEART_BEAT_COMMAND))
} // here : during & pace for heart-beat
.exec(ws("close").close)
However, if I actually run it, it seems that the exec inside pace is not executed.
I noticed the difference between the working version and the non-working version.
The difference seems to be the difference in message format when you do ws.sendText.
[Expected Working version]
...
.during(testDuringTime) {
pace(5.second).exec(ws("TEST").sendText("HEARTBEAT")) // just send HEARTBEAT message. it's work
}
[Non Working Version]
...
.during(testDuringTime) {
pace(5.second).exec(ws("TEST").sendText(HEART_BEAT_COMMAND)) // Heart-Beat Command String not working
}
private val HEART_BEAT_COMMAND: String =
"""|HEARTBEAT
>
>\u0000""".stripMargin
I don’t know what the difference between these two works or not…
2021년 4월 17일 토요일 오후 7시 7분 48초 UTC+9에 Stéphane Landelle님이 작성:
Oh, I think this is a problem with my code. It seems to have occurred because the command for HEART-BEAT in stomp protocol is wrong. HEARTBEAT command should just be \n.
I’ll close this question Thank you for checking!
2021년 4월 19일 월요일 오후 3시 53분 27초 UTC+9에 heesuk님이 작성: