Translating chrome console messages into Gatling websocket message

I have been trying to translate the output from chrome console into the proper scala syntax, i.e.


val connect: String = “”"{
“accept-version” : “1.1,1.0”,
“heart-beat”: “10000,10000”

On success this should return a Connected message from my server. However Gatling is complaining about error message 1007
( 1007 indicates that an endpoint is terminating the connection

  • because it has received data within a message that was not
  • consistent with the type of the message (e.g., non-UTF-8 [RFC3629]
  • data within a text message).)

Could someone please take a look if I have translated the message incorrectly?
Thank you!

Why do you convert into JSON???

I’m trying to follow the Stomp protocol

for example



Thank you

Exactly, so you should just copy-paste what you get in Chrome!

I have tried that approach, however it is still returning 1007 status. Stomp accepts UTF-8 encoded text messages, is there a way to force the String into UTF-8 encoding?

Gatling uses UTF-8 by default (see gatling.conf).

Hi Stephane,
I have tried various methods of setting the text I send to utf-8 (gatling.conf as you mentioned, setting up JVM to use “JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8”, and also tried to convert the message with a java helper method

public String ConvertToUTF8(String s) {
String out = null;
try {
out = new String(s.getBytes(“UTF-8”), “ISO-8859-1”);
} catch ( e) {
return out;
return out;

None of these seem to work, I’m still getting the error message

Websocket ‘gatling.http.webSocket’ was unexpectedly closed with status 1007 and message.

Any other suggestions that I can try?

Please provide a reproducer.

Here’s my code:

val connect: String = s""“CONNECT\naccept-version:1.1,1.0\nheart-beat:10000,10000\n\n\u0000"”"

val scn = scenario(“WebSocket”)
.exec(ws(“OpenWebSocket”).open(websocketURL).check(wsAwait.within(30 seconds).until(1).regex(“o”).saveAs(“oResponse”)))
.pause(5 seconds)

.check(wsListen.within(30 seconds).until(1).regex(""“CONNECTED”"").saveAs(“connectResponse”)))

my stomp server returns o and I can check for heartbeats if I don’t send any messages. However the moment I send anything the connection is closed.

Thank you

A reproducer means providing an app/server too.

I don’t have a publicly accessible stomp server at the moment, I’ll have to set one up. If this doesn’t work, do you suggest any work around using other stomp client libraries and if so how can they be integrated with Gatling?

You can just provide a light app that can be installed anywhere.

I solved the problem, the encoding was correct, it was the square brackets that were not escaped properly. I figured this out when using to debug my websocket server.

Strange, but glad you found it out.