Opcode :text in Tsung load test for Phoenix Channels

Hi folks

I am trying to run a simple Tsung load test for WS

here is my scenario

<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/user/share/tsung/tsung-1.0.dtd">
<tsung loglevel="debug" version="1.0">
  <clients>
    <client host="localhost" use_controller_vm="true" />
  </clients>
  <servers>
    <server host="docker.for.mac.localhost" port="4000" type="tcp" />
  </servers>
  <load>
    <arrivalphase phase="1" duration="100" unit="second">
      <users maxnumber="10" arrivalrate="5" unit="second" />
    </arrivalphase>
  </load>
  <options>
    <option name="ports_range" min="1025" max="65535"/>
  </options>
  <sessions>
    <session name="websocket" probability="100" type="ts_websocket">
      <request>
        <websocket type="connect" path="/socket/websocket?vsn=2.0.0&amp;token=someJWThere"></websocket>
      </request>
      <request subst="true">
        <websocket type="message">["1","1","room:1","phx_join",{}]</websocket>
      </request>
      <for var="i" from="1" to="1000" incr="1">
        <thinktime value="30"/>
      </for>
    </session>
  </sessions>
</tsung>

which generates opcode: :binary here phoenix/v2_json_serializer.ex at master · phoenixframework/phoenix · GitHub

what should I specify in the request to get opcode: :text ?

So, if anybody interested, adding the option frame="text" solved the case

here is the final XML

<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/user/share/tsung/tsung-1.0.dtd">
<tsung loglevel="debug" version="1.0">
  <clients>
    <client host="localhost" use_controller_vm="true" maxusers="20000" />
  </clients>

  <servers>
    <server host="docker.for.mac.localhost" port="4000" type="tcp" />
  </servers>

  <load>
    <arrivalphase phase="1" duration="120" unit="second">
      <users maxnumber="10000" arrivalrate="200" unit="second" />
    </arrivalphase>
  </load>

  <options>
    <option name="ports_range" min="1025" max="65535"/>
  </options>

  <sessions>

    <session name="websocket" probability="100" type="ts_websocket">
      <request subst="true">
        <websocket type="connect" path="/socket/websocket?vsn=2.0.0&amp;token=myJWThere"></websocket>
      </request>

      <request subst="true">
        <websocket type="message" frame="text">["%%ts_user_server:get_unique_id%%","%%ts_user_server:get_unique_id%%","room:%%ts_user_server:get_unique_id%%","phx_join",{}]</websocket>
      </request>

      <for var="i" from="1" to="1000" incr="1">
        <thinktime value="20"/>

        <request subst="true">
          <websocket type="message" frame="text">[null,"%%ts_user_server:get_unique_id%%","phoenix","heartbeat",{}]</websocket>
        </request>
      </for>
    </session>
  </sessions>
</tsung>
3 Likes