|
|
|
@ -102,7 +102,7 @@ Testing websocket client support</h1>
|
|
|
|
|
<p>If you run the test server as described above, you can also connect to it using the test client as well as a browser.</p>
|
|
|
|
|
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> $ libwebsockets-test-client localhost</div></div><!-- fragment --><p>will by default connect to the test server on localhost:7681 and print the dumb increment number from the server at the same time as drawing random circles in the mirror protocol; if you connect to the test server using a browser at the same time you will be able to see the circles being drawn.</p>
|
|
|
|
|
<p>The test client supports SSL too, use</p>
|
|
|
|
|
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> $ libwebsockets-test-client localhost --ssl -s</div></div><!-- fragment --><p>the -s tells it to accept the default selfsigned cert from the server, otherwise it will strictly fail the connection if there is no CA cert to validate the server's certificate.</p>
|
|
|
|
|
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> $ libwebsockets-test-client localhost --ssl -s</div></div><!-- fragment --><p>the -s tells it to accept the default self-signed cert from the server, otherwise it will strictly fail the connection if there is no CA cert to validate the server's certificate.</p>
|
|
|
|
|
<h1><a class="anchor" id="choosingts"></a>
|
|
|
|
|
Choosing between test server variations</h1>
|
|
|
|
|
<p>If you will be doing standalone serving with lws, ideally you should avoid making your own server at all, and use lwsws with your own protocol plugins.</p>
|
|
|
|
@ -114,13 +114,13 @@ Testing simple echo</h1>
|
|
|
|
|
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> $ libwebsockets-test-echo --client echo.websocket.org</div></div><!-- fragment --><p>This echo test is of limited use though because it doesn't negotiate any protocol. You can run the same test app as a local server, by default on localhost:7681 </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> $ libwebsockets-test-echo</div></div><!-- fragment --><p> and do the echo test against the local echo server </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> $ libwebsockets-test-echo --client localhost --port 7681</div></div><!-- fragment --><p> If you add the <code>--ssl</code> switch to both the client and server, you can also test with an encrypted link.</p>
|
|
|
|
|
<h1><a class="anchor" id="tassl"></a>
|
|
|
|
|
Testing SSL on the client side</h1>
|
|
|
|
|
<p>To test SSL/WSS client action, just run the client test with </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> $ libwebsockets-test-client localhost --ssl</div></div><!-- fragment --><p> By default the client test applet is set to accept selfsigned certificates used by the test server, this is indicated by the <code>use_ssl</code> var being set to <code>2</code>. Set it to <code>1</code> to reject any server certificate that it doesn't have a trusted CA cert for.</p>
|
|
|
|
|
<p>To test SSL/WSS client action, just run the client test with </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> $ libwebsockets-test-client localhost --ssl</div></div><!-- fragment --><p> By default the client test applet is set to accept self-signed certificates used by the test server, this is indicated by the <code>use_ssl</code> var being set to <code>2</code>. Set it to <code>1</code> to reject any server certificate that it doesn't have a trusted CA cert for.</p>
|
|
|
|
|
<h1><a class="anchor" id="taping"></a>
|
|
|
|
|
Using the websocket ping utility</h1>
|
|
|
|
|
<p>libwebsockets-test-ping connects as a client to a remote websocket server and pings it like the normal unix ping utility. </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> $ libwebsockets-test-ping localhost</div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> handshake OK for protocol lws-mirror-protocol</div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> Websocket PING localhost.localdomain (127.0.0.1) 64 bytes of data.</div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> 64 bytes from localhost: req=1 time=0.1ms</div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> 64 bytes from localhost: req=2 time=0.1ms</div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> 64 bytes from localhost: req=3 time=0.1ms</div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> 64 bytes from localhost: req=4 time=0.2ms</div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> 64 bytes from localhost: req=5 time=0.1ms</div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> 64 bytes from localhost: req=6 time=0.2ms</div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> 64 bytes from localhost: req=7 time=0.2ms</div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> 64 bytes from localhost: req=8 time=0.1ms</div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> ^C</div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> --- localhost.localdomain websocket ping statistics ---</div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> 8 packets transmitted, 8 received, 0% packet loss, time 7458ms</div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> rtt min/avg/max = 0.110/0.185/0.218 ms</div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> $</div></div><!-- fragment --><p> By default it sends 64 byte payload packets using the 04 PING packet opcode type. You can change the payload size using the <code>-s=</code> flag, up to a maximum of 125 mandated by the 04 standard.</p>
|
|
|
|
|
<p>Using the lws-mirror protocol that is provided by the test server, libwebsockets-test-ping can also use larger payload sizes up to 4096 is BINARY packets; lws-mirror will copy them back to the client and they appear as a PONG. Use the <code>-m</code> flag to select this operation.</p>
|
|
|
|
|
<p>The default interval between pings is 1s, you can use the -i= flag to set this, including fractions like <code>-i=0.01</code> for 10ms interval.</p>
|
|
|
|
|
<p>Before you can even use the PING opcode that is part of the standard, you must complete a handshake with a specified protocol. By default lws-mirror-protocol is used which is supported by the test server. But if you are using it on another server, you can specify the protcol to handshake with by <code>--protocol=protocolname</code></p>
|
|
|
|
|
<p>Before you can even use the PING opcode that is part of the standard, you must complete a handshake with a specified protocol. By default lws-mirror-protocol is used which is supported by the test server. But if you are using it on another server, you can specify the protocol to handshake with by <code>--protocol=protocolname</code></p>
|
|
|
|
|
<h1><a class="anchor" id="ta"></a>
|
|
|
|
|
fraggle Fraggle test app</h1>
|
|
|
|
|
<p>By default it runs in server mode </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> $ libwebsockets-test-fraggle</div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> libwebsockets test fraggle</div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> (C) Copyright 2010-2011 Andy Green <andy@warmcat.com> licensed under LGPL2.1</div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span>  Compiled with SSL support, not using it</div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span>  Listening on port 7681</div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> server sees client connect</div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> accepted v06 connection</div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> Spamming 360 random fragments</div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> Spamming session over, len = 371913. sum = 0x2D3C0AE</div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> Spamming 895 random fragments</div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> Spamming session over, len = 875970. sum = 0x6A74DA1</div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> ...</div></div><!-- fragment --><p> You need to run a second session in client mode, you have to give the <code>-c</code> switch and the server address at least: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> $ libwebsockets-test-fraggle -c localhost</div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> libwebsockets test fraggle</div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> (C) Copyright 2010-2011 Andy Green <andy@warmcat.com> licensed under LGPL2.1</div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span>  Client mode</div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> Connecting to localhost:7681</div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> denied deflate-stream extension</div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> handshake OK for protocol fraggle-protocol</div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> client connects to server</div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> EOM received 371913 correctly from 360 fragments</div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> EOM received 875970 correctly from 895 fragments</div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> EOM received 247140 correctly from 258 fragments</div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> EOM received 695451 correctly from 692 fragments</div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> ...</div></div><!-- fragment --><p> The fraggle test sends a random number up to 1024 fragmented websocket frames each of a random size between 1 and 2001 bytes in a single message, then sends a checksum and starts sending a new randomly sized and fragmented message.</p>
|
|
|
|
@ -170,7 +170,7 @@ Autobahn Test Suite</h1>
|
|
|
|
|
<p>to see the results</p>
|
|
|
|
|
<h1><a class="anchor" id="autobahnnotes"></a>
|
|
|
|
|
Autobahn Test Notes</h1>
|
|
|
|
|
<p>1) Autobahn tests the user code + lws implementation. So to get the same results, you need to follow test-echo.c in terms of user implmentation.</p>
|
|
|
|
|
<p>1) Autobahn tests the user code + lws implementation. So to get the same results, you need to follow test-echo.c in terms of user implementation.</p>
|
|
|
|
|
<p>2) Two of the tests make no sense for Libwebsockets to support and we fail them.</p>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>Tests 2.10 + 2.11: sends multiple pings on one connection. Lws policy is to only allow one active ping in flight on each connection, the rest are dropped. The autobahn test itself admits this is not part of the standard, just someone's random opinion about how they think a ws server should act. So we will fail this by design and it is no problem about RFC6455 compliance. </li>
|
|
|
|
|