processone / tsung

Tsung is a high-performance benchmark framework for various protocols including HTTP, XMPP, LDAP, etc.
http://www.process-one.net/en/tsung/
GNU General Public License v2.0
2.54k stars 405 forks source link

http_header and origin doesn't work for 'websocket' type #364

Open rawmind opened 4 years ago

rawmind commented 4 years ago

Tsung version: 1.7.1_dev Platform: mac

tsung test case

<?xml version="1.0" ?>
<!DOCTYPE tsung SYSTEM "/Users/akovrov/opt/tsung-1.7.0/share/tsung/tsung-1.0.dtd">
<tsung loglevel="debug">
  <clients>
    <client host="localhost" use_controller_vm="true" maxusers="100"/>
  </clients>

  <servers>
          <server host="some.lvh.me" port="3000" type="websocket"/>
  </servers>

  <load>
    <arrivalphase phase="1" duration="1000" unit="second">
      <users maxnumber="100" arrivalrate="1" unit="second"/>
    </arrivalphase>
  </load>

  <options>
    <option name="ports_range" min="16000" max="16300"/>
    <option name="websocket_subprotocols" value="actioncable-v1-json, actioncable-unsupported"/>
    <option name="websocket_frame" value="text"/>
     <option name="websocket_path" value="/cable"/>
  </options>

<sessions>
    <session name="websocket"  probability="100" type="ts_websocket">
      <request>
              <websocket type="connect" origin="test.me" path="/cable" subprotocols="actioncable-v1-json, actioncable-unsupported">
                      <http_header name="Cookie" value="user.id=valvalval;"/>
              </websocket>
      </request>
      <thinktime value="2"/>

      <!-- stay connected -->
      <for var="hb" from="1" to="9999" incr="1">
        <thinktime value="10"/>
      </for> 

    </session>
  </sessions>

</tsung>

tcpdump -A port 3000

GET /cable HTTP/1.1
Host: some.lvh.me
Upgrade: websocket
Connection: Upgrade
Origin: some.lvh.me
Sec-WebSocket-Key: TLP4kXl5AJnP1cTxgueQcw==
Sec-WebSocket-Version: 13
Sec-WebSocket-Protocol: actioncable-v1-json, actioncable-unsupported

With 'tcp' / 'ssl' type all works fine beside websocket options (websocket_subprotocols, websocket_frame, etc)