Translating chrome console messages into Gatling websocket message

338 views
Skip to first unread message

Ka Chun

unread,
Mar 26, 2015, 5:49:17 PM3/26/15
to gat...@googlegroups.com
Hi,
I have been trying to translate the output from chrome console into the proper scala syntax, i.e.
["CONNECT\naccept-version:1.1,1.0\nheart-beat:10000,10000\n\n\u0000"]
to 
  val connect: String = """{
    "CONNECT",
    "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!

Stéphane LANDELLE

unread,
Mar 27, 2015, 5:10:09 AM3/27/15
to gat...@googlegroups.com
Why do you convert into JSON???

Stéphane Landelle
Lead developer


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ka Chun

unread,
Mar 27, 2015, 8:34:17 AM3/27/15
to gat...@googlegroups.com
Hi,
I'm trying to follow the Stomp protocol


for example
CONNECT
accept-version:1.0,1.1,2.0
host:stomp.github.org

^@
Thank you

Stéphane LANDELLE

unread,
Mar 27, 2015, 9:59:01 AM3/27/15
to gat...@googlegroups.com
Exactly, so you should just copy-paste what you get in Chrome!

Stéphane Landelle
Lead developer


Ka Chun

unread,
Mar 27, 2015, 10:12:43 AM3/27/15
to gat...@googlegroups.com
Update:
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?
Thanks

Stéphane LANDELLE

unread,
Mar 27, 2015, 10:48:58 AM3/27/15
to gat...@googlegroups.com
Gatling uses UTF-8 by default (see gatling.conf).

Stéphane Landelle
Lead developer


Ka Chun

unread,
Mar 27, 2015, 12:15:28 PM3/27/15
to gat...@googlegroups.com
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 (java.io.UnsupportedEncodingException 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?
Thanks

Stéphane LANDELLE

unread,
Mar 27, 2015, 12:35:13 PM3/27/15
to gat...@googlegroups.com
Please provide a reproducer.

Stéphane Landelle
Lead developer


Ka Chun

unread,
Mar 27, 2015, 2:30:05 PM3/27/15
to gat...@googlegroups.com
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)
  
 .exec(ws("Connect")
 .sendText(connect)
 .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

Stéphane LANDELLE

unread,
Mar 27, 2015, 4:15:02 PM3/27/15
to gat...@googlegroups.com
A reproducer means providing an app/server too.

Stéphane Landelle
Lead developer


Ka Chun

unread,
Mar 27, 2015, 4:59:38 PM3/27/15
to gat...@googlegroups.com
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?
Thanks

Stéphane LANDELLE

unread,
Apr 1, 2015, 5:52:18 AM4/1/15
to gat...@googlegroups.com
You can just provide a light app that can be installed anywhere.

Stéphane Landelle
Lead developer


Ka Chun

unread,
Apr 2, 2015, 12:02:12 PM4/2/15
to gat...@googlegroups.com
Hi,
I solved the problem, the encoding was correct, it was the square brackets that were not escaped properly. I figured this out when using https://chrome.google.com/webstore/detail/simple-websocket-client/pfdhoblngboilpfeibdedpjgfnlcodoo?hl=en to debug my websocket server.
Thanks

Stéphane LANDELLE

unread,
Apr 2, 2015, 1:24:08 PM4/2/15
to gat...@googlegroups.com
Strange, but glad you found it out.

Stéphane Landelle
Lead developer


Reply all
Reply to author
Forward
0 new messages