1 Building the library and test apps
2 ----------------------------------
4 You need to regenerate the autotools and libtoolize stuff for your system
11 ./configure --prefix=/usr --libdir=/usr/lib64 --enable-openssl
15 Christopher Baker reported that this is needed
16 (and I was told separately enabling openssl makes trouble somehow)
18 ./configure CC="gcc -arch i386 -arch x86_64" CXX="g++ -arch i386 -arch
19 x86_64" CPP="gcc -E" CXXCPP="g++ -E" --enable-nofork
23 I did the following to get working build, ping test is disabled when
26 1) install mingw64_w32 compiler packages from Fedora
27 2) additionally install mingw64-zlib package
28 3) ./configure --prefix=/usr --enable-mingw --host=x86_64-w64-mingw32
31 ------MIPS cross-build using OpenWRT
33 ./configure --prefix=/usr --without-extensions --host mips-openwrt-linux
35 I did not try building the extensions since they need cross-zlib, but it
36 should also be workable.
40 you may need --enable-builtin-getifaddrs if your toolchain
41 doesn't have it - openWRT uclibc has it so you don't need this option.
45 ./configure --prefix=/usr --host=arm-linux-gnueabi --without-client --without-extensions
47 you can build cross with client and extensions perfectly well, but
48 apart from the size shrink this has the nice characteristic that no
49 non-toolchain libraries are needed to build it.
52 otherwise if /usr/local/... and /usr/local/lib are OK then...
56 $ make && sudo make install
57 $ libwebsockets-test-server
59 should be enough to get a test server listening on port 7861.
62 Configure script options
63 ------------------------
65 There are several other possible configure options
67 --enable-libcrypto by default libwebsockets uses its own
68 built-in md5 and sha-1 implementation for
69 simplicity. However the libcrypto ones
70 may be faster, and in a distro context it
71 may be highly desirable to use a common
72 library implementation for ease of security
73 upgrades. Give this configure option
74 to disable the built-in ones and force use
75 of the libcrypto (part of openssl) ones.
77 --with-client-cert-dir=dir tells the client ssl support where to
78 look for trust certificates to validate
79 the remote certificate against.
81 --enable-noping Don't try to build the ping test app
82 It needs some unixy environment that
83 may choke in other build contexts, this
84 lets you cleanly stop it being built
86 --enable-builtin-getifaddrs if your libc lacks getifaddrs, you can build an
87 implementation into the library. By default your libc
90 --without-testapps Just build the library not the test apps
92 --without-client Don't build the client part of the library nor the
93 test apps that need the client part. Useful to
94 minimize library footprint for embedded server-only
97 --without-server Don't build the server part of the library nor the
98 test apps that need the server part. Useful to
99 minimize library footprint for embedded client-only
102 --without-daemonize Don't build daemonize.c / lws_daemonize
104 --disable-debug Remove all debug logging below lwsl_notice in severity
105 from the code -- it's not just defeated from logging
106 but removed from compilation
108 --without-extensions Remove all code and data around protocol extensions.
109 This reduces the code footprint considerably but
110 you will lose extension features like compression.
111 However that may be irrelevant for embedded use and
112 the code / data size / speed improvements may be
115 --with-latency Builds the latency-tracking code into the library...
116 this slows your library down a bit but is very useful
117 to find the cause of unexpected latencies occurring
118 inside the library. See README.test-apps for more
122 Externally configurable important constants
123 -------------------------------------------
125 You can control these from configure by just setting them as commandline
126 args throgh CFLAGS, eg
128 ./configure CFLAGS="-DLWS_MAX_ZLIB_CONN_BUFFER=8192"
131 They all have reasonable defaults usable for all use-cases except resource-
132 constrained, so you only need to take care about them if you want to tune them
133 to the amount of memory available.
135 - LWS_MAX_HEADER_NAME_LENGTH default 64: max characters in an HTTP header
136 name that libwebsockets can cope with
138 - LWS_MAX_HEADER_LEN default 4096: largest HTTP header value string length
139 libwebsockets can cope with
141 - LWS_INITIAL_HDR_ALLOC default 256: amount of memory to allocate initially,
142 tradeoff between taking too much and needless realloc
144 - LWS_ADDITIONAL_HDR_ALLOC default 64: how much to additionally realloc if
145 the header value string keeps coming
147 - MAX_USER_RX_BUFFER default 4096: max amount of user rx data to buffer at a
148 time and pass to user callback LWS_CALLBACK_RECEIVE or
149 LWS_CALLBACK_CLIENT_RECEIVE. Large frames are passed to the user callback
150 in chunks of this size. Tradeoff between per-connection static memory
151 allocation and if you expect to deal with large frames, how much you can
152 see at once which can affect efficiency.
154 - LWS_MAX_PROTOCOLS default 10: largest amount of different protocols the
157 - LWS_MAX_EXTENSIONS_ACTIVE default 10: largest amount of extensions we can
158 choose to have active on one connection
160 - SPEC_LATEST_SUPPORTED default 13: only change if you want to remove support
161 for later protocol versions... unlikely
163 - AWAITING_TIMEOUT default 5: after this many seconds without a response, the
164 server will hang up on the client
166 - CIPHERS_LIST_STRING default "DEFAULT": SSL Cipher selection. It's advisable
167 to tweak the ciphers allowed to be negotiated on secure connections for
168 performance reasons, otherwise a slow algorithm may be selected by the two
169 endpoints and the server could expend most of its time just encrypting and
170 decrypting data, severely limiting the amount of messages it will be able to
171 handle per second. For example::
173 "RC4-MD5:RC4-SHA:AES128-SHA:AES256-SHA:HIGH:!DSS:!aNULL"
175 - SYSTEM_RANDOM_FILEPATH default "/dev/urandom": if your random device differs
178 - LWS_MAX_ZLIB_CONN_BUFFER maximum size a compression buffer is allowed to
179 grow to before closing the connection. Some limit is needed or any connecton
180 can exhaust all server memory by sending it 4G buffers full of zeros which the
181 server is expect to expand atomically. Default is 64KBytes.
183 - LWS_SOMAXCONN maximum number of pending connect requests the listening
184 socket can cope with. Default is SOMAXCONN. If you need to use synthetic
185 tests that just spam hundreds of connect requests at once without dropping
186 any, you can try messing with these as well as ulimit (see later)
187 (courtesy Edwin van der Oetelaar)
189 echo "2048 64512" > /proc/sys/net/ipv4/ip_local_port_range
190 echo "1" > /proc/sys/net/ipv4/tcp_tw_recycle
191 echo "1" > /proc/sys/net/ipv4/tcp_tw_reuse
192 echo "10" > /proc/sys/net/ipv4/tcp_fin_timeout
193 echo "65536" > /proc/sys/net/core/somaxconn
194 echo "65536" > /proc/sys/net/ipv4/tcp_max_syn_backlog
195 echo "262144" > /proc/sys/net/netfilter/nf_conntrack_max
201 Update at 35f332bb46464feb87eb
203 Embedded server-only configuration without extensions (ie, no compression
204 on websocket connections), but with full v13 websocket features and http
205 server, built on ARM Cortex-A9:
207 ./configure --without-client --without-extensions --disable-debug --enable-nofork --without-daemonize
209 .text .rodata .data .bss
212 Context Creation, 1024 fd limit[2]: 12288 (12 bytes per fd)
213 Per-connection [3]: 4400 bytes
216 This shows the impact of the major configuration with/without options at
217 13ba5bbc633ea962d46d using Ubuntu ARM on a PandaBoard ES.
219 These are accounting for static allocations from the library elf, there are
220 additional dynamic allocations via malloc
222 Static allocations, ARM9
223 .text .rodata .data .bss
224 All (no without) 35024 9940 336 4104
225 without client 25684 7144 336 4104
226 without client, exts 21652 6288 288 4104
227 without client, exts, debug[1] 19756 3768 288 4104
228 without server 30304 8160 336 4104
229 without server, exts 25382 7204 288 4104
230 without server, exts, debug[1] 23712 4256 288 4104
232 Dynamic allocations: ARM9 (32 bit)
234 Context Creation, 1024 fd limit[2] in ulimit: 12288 (12 bytes per fd)
235 Per-connection (excluding headers[3]): 8740
237 Dynamic allocations: x86_64 (64 bit)
239 Context Creation, 1024 fd limit[2] in ulimit: 16384 (16 bytes per fd)
240 Per-connection (excluding headers[3]): 9224
242 [1] --disable-debug only removes messages below lwsl_notice. Since that is
243 the default logging level the impact is not noticable, error, warn and notice
244 logs are all still there.
246 [2] 1024 fd per process is the default limit (set by ulimit) in at least Fedora
249 [3] known headers are retained via additional mallocs for the lifetime of the