title: Tsung load testing for MongooseIM (websockets)
body: <p>My question is about configuring my tsung.xml file to load-test chat application. </p>
  
  <p>So, we have our MongooseIM server on the server side, jsjac.js library for our web-based client. We use xmpp and websockets to communicate.</p>
  
  <p>httpbase for jsjac is looks like <code>ws://hostname:5288/ws-xmpp/</code> and this part works fine for me. Tsung is supports websockets "from the box" and everybody says that the best way to test websockets - is to use tsung. But there is not so much information about how to do that.</p>
  
  <p>Here is my tsung.xml:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd"&gt;
  &lt;tsung loglevel="notice" version="1.0"&gt;
    &lt;clients&gt;
      &lt;client host="localhost" use_controller_vm="true" maxusers="10" /&gt;
    &lt;/clients&gt;
  
    &lt;servers&gt;
      &lt;server host="hostname" port="5288" type="tcp" /&gt;
    &lt;/servers&gt;
  
    &lt;load&gt;
      &lt;arrivalphase phase="1" duration="10" unit="second"&gt;
        &lt;users maxnumber="1" arrivalrate="1" unit="second" /&gt;
      &lt;/arrivalphase&gt;
    &lt;/load&gt;
  
    &lt;sessions&gt;
      &lt;session name="websocket" probability="100" type="ts_websocket"&gt;
          &lt;request subst="true"&gt;
               &lt;websocket type="connect" path="/ws-xmpp"&gt;&lt;/websocket&gt;
          &lt;/request&gt;
  
          &lt;request&gt;
              &lt;dyn_variable name="uid" jsonpath="uid"/&gt;
              &lt;websocket type="message"&gt;{"user":"bob", "password":"bob"}&lt;/websocket&gt;
          &lt;/request&gt;  
  
          &lt;request subst="true"&gt;
              &lt;match do="log" when="nomatch"&gt;ok&lt;/match&gt;
              &lt;websocket type="message"&gt;{"uid":"%%_uid%%", "data":"data"}&lt;/websocket&gt;
          &lt;/request&gt;
  
          &lt;request&gt;
          &lt;websocket type ="message"&gt;{"key":"value"}&lt;/websocket&gt;      
          &lt;/request&gt;
  
          &lt;request&gt;
              &lt;websocket type="close"&gt;&lt;/websocket&gt;
          &lt;/request&gt;
      &lt;/session&gt;
    &lt;/sessions&gt;
  &lt;/tsung&gt;
  </code></pre>
  
  <p>and after test passed the result is:</p>
  
  <pre><code>connected: 0
  finish_users_count: 1
  users: 1
  users count: 1
  websocket_succ: 1
  </code></pre>
  
  <p>user "bob" is really exist in server's db and works fine via client application.</p>
  
  <p>Can anybody tell me what i'm doing wrong?<br>
  Or maybe someone could provide a link to some article or working xml file?<br>
  Thanks.</p>