blob: f10520e14308aa4ea8bdcbe6f3b95b4dd738bcbb [file] [log] [blame]
Andy Greenb2149772010-10-31 13:15:56 +00001Using test-server as a quickstart
2---------------------------------
3
Andy Greena1e3ec02010-11-08 17:16:50 +00004For a Fedora x86_86 box, the following config line was
5needed:
6
7./configure --prefix=/usr --libdir=/usr/lib64 --enable-openssl
8
9otherwise if /usr/local/... and /usr/local/lib are OK then...
10
Andy Green3c974692010-11-08 17:04:09 +000011$ ./configure --enable-openssl
Andy Green9293b052011-01-23 17:53:54 +000012$ make clean
Andy Green05a0a7b2010-10-31 17:51:39 +000013$ make
Andy Green7310e9c2010-11-01 09:12:17 +000014$ sudo make install
15$ libwebsockets-test-server
Andy Greenb2149772010-10-31 13:15:56 +000016
17should be enough to get a test server listening on port 7861.
18
Andy Green9293b052011-01-23 17:53:54 +000019There are a couple of other possible configure options
20
21--enable-nofork disables the fork into the background API
22 and removes all references to fork() and
23 pr_ctl() from the sources. Use it if your
24 platform doesn't support forking.
25
26--enable-libcrypto by default libwebsockets uses its own
27 built-in md5 and sha-1 implementation for
28 simplicity. However the libcrypto ones
29 may be faster, and in a distro context it
30 may be highly desirable to use a common
31 library implementation for ease of security
32 upgrades. Give this configure option
33 to disable the built-in ones and force use
34 of the libcrypto (part of openssl) ones.
35
Andy Green90c7cbc2011-01-27 06:26:52 +000036--with-client-cert-dir=dir tells the client ssl support where to
37 look for trust certificates to validate
38 the remote certificate against.
39
Andy Green4739e5c2011-01-22 12:51:57 +000040Testing server with a browser
41-----------------------------
Andy Greened11a022011-01-20 10:23:50 +000042
Andy Greenb2149772010-10-31 13:15:56 +000043If you point your browser (eg, Chrome) to
44
45 http://127.0.0.1:7681
46
Andy Green3c974692010-11-08 17:04:09 +000047It will fetch a script in the form of test.html, and then run the
Andy Green7310e9c2010-11-01 09:12:17 +000048script in there on the browser to open a websocket connection.
49Incrementing numbers should appear in the browser display.
Andy Greenb2149772010-10-31 13:15:56 +000050
Andy Green90c7cbc2011-01-27 06:26:52 +000051Using SSL on the server side
52----------------------------
Andy Green4739e5c2011-01-22 12:51:57 +000053
Andy Green3c974692010-11-08 17:04:09 +000054To test it using SSL/WSS, just run the test server with
55
56$ libwebsockets-test-server --ssl
57
58and use the URL
59
60 https://127.0.0.1:7681
61
62The connection will be entirely encrypted using some generated
63certificates that your browser will not accept, since they are
64not signed by any real Certificate Authority. Just accept the
65certificates in the browser and the connection will proceed
66in first https and then websocket wss, acting exactly the
67same.
68
Andy Greenb2149772010-10-31 13:15:56 +000069test-server.c is all that is needed to use libwebsockets for
70serving both the script html over http and websockets.
71
Andy Green90c7cbc2011-01-27 06:26:52 +000072
Andy Greened11a022011-01-20 10:23:50 +000073Forkless operation
74------------------
75
76If your target device does not offer fork(), you can use
77libwebsockets from your own main loop instead. Use the
78configure option --nofork and simply call libwebsocket_service()
79from your own main loop as shown in the test app sources.
80
Andy Green90c7cbc2011-01-27 06:26:52 +000081
Andy Green4739e5c2011-01-22 12:51:57 +000082Testing websocket client support
83--------------------------------
84
85If you run the test server as described above, you can also
86connect to it using the test client as well as a browser.
87
88$ libwebsockets-test-client localhost
89
90will by default connect to the test server on localhost:7681
91and print the dumb increment number from the server at the
92same time as drawing random circles in the mirror protocol;
93if you connect to the test server using a browser at the
94same time you will be able to see the circles being drawn.
95
Andy Greened11a022011-01-20 10:23:50 +000096
Andy Green90c7cbc2011-01-27 06:26:52 +000097Testing SSL on the client side
98------------------------------
99
100To test SSL/WSS client action, just run the client test with
101
102$ libwebsockets-test-client localhost --ssl
103
104By default the client test applet is set to accept selfsigned
105certificates used by the test server, this is indicated by the
106use_ssl var being set to 2. Set it to 1 to reject any server
107certificate that it doesn't have a trusted CA cert for.
108
109
Andy Greened11a022011-01-20 10:23:50 +0000110Websocket version supported
111---------------------------
112
Andy Green4739e5c2011-01-22 12:51:57 +0000113The websocket client code is 04 version, the server supports
114both 00/76 in text mode and 04 dynamically per-connection
115depending on the version of the client / browser.
Andy Greened11a022011-01-20 10:23:50 +0000116
Andy Green4739e5c2011-01-22 12:51:57 +00001172011-01-22 Andy Green <andy@warmcat.com>
Andy Greenb2149772010-10-31 13:15:56 +0000118