Libwebsockets is a lightweight pure C library built to use minimal CPU and memory resources, and provide fast throughput in both directions as client or server.
Realtime web applications powered by libwebsockets
Try the bundled test server live in SSL mode
This is the default libwebsockets test server running on an Arm Cortex A53
Development Stable
master | github | local gitweb v2.4-stable | github | local gitweb
changelog changelog
API reference API reference
ABI compatibility history

libwebsockets v2.4 released 2017-10-16

  • HTTP/2 support is here!
  • mbedTLS is now also usable as a backend in place of OpenSSL.
  • ssh2 server plugin provided allowing adding a vhost users can connect to using ssh + RSA keys.
  • New generic hash and multi-tail ringbuffer apis.
  • Valgrind and Coverity-clean.
See the changelog link above for more details.

libwebsockets v2.3 released 2017-07-28

v2.3 adds many fixes and features, including the new "lws-meta" multiplexing protocol. See the changelog link above for details.

libwebsockets v2.2 released 2017-03-08

v2.2 adds support for ESP32 ^^, serving gzipped-compressed files directly from inside a zip, raw file and socket integration, full RFC7233 RANGES support, Basic Auth security per-mount, and many more new features and improvements. See the changelog link above for more details.

libwebsockets v2.1 released 2016-10-06

Building on v2.0, v2.1 adds many new features to lwsws and new plugins, as well as new API support like multipart formas and file upload. The documentation has been reworked using Doxygen. ESP8266 is also supported ^^ See the changelog above for more info.

libwebsockets v2.0 released 2016-05-05

Read about the large number of new features here
  • Backwards-compatible with v1.7
  • New unlimited vhosts / listen sockets with own SSL certs
  • Auto-serving "mounts" map URL space to directories, CGIs, or redirects
  • Websocket protocols can be provided a lws protocol plugins
  • LWSWS standalone webserver (used by this site) lets you configure lws features by JSON and avoid writing any code

libwebsockets features

  • Provides server and client APIs for RFC6455 v13 ws:// and wss:// websocket protocol, along with http:// and https://
  • Can be configured to use OpenSSL, CyaSSL, WolfSSL, BoringSSL and mbedTLS to provide fully encrypted client and server links - including client certificate support
  • HTTP/2 server support integrated on same listen port as http/1 and ws[s], ALPN supported
  • Lightweight and fast even at 250K connections per thread and beyond - performance per byte and performance per MIPS many times better than traditional solutions
  • CMake based project that has been used in a variety of OS contexts including Linux (uclibc and glibc), ARM-based embedded boards, OP-TEE, MIPS / OpenWRT, Windows, Android, Apple iOS and even Tivo. It's used all over the place including The New York Times customer-facing servers and BMW.
  • It includes a stub webserver that is enough to deliver your scripts to the browser that open websocket connections back to the same server, so it can solve the entire server side, ws://, wss://, http://, and https:// in one step. Apache, Java or any other server-side support is not needed.
  • Compliant browsers from the last few years are supported on any platform.
  • Architectural features like nonblockinng event loop, zero-copy for payload data and FSM-based protocol parsers make it ideal for realtime operation on resource-constrained devices
  • Simple, pure C: user code creates a libwebsockets context with options and a callback, library calls the callback when events occur on the connection - no activity on connections == 0% CPU
  • Posix poll(), libev, libevent and libuv event loops supported
  • Proxy support, including Basic Auth

libwebsockets extensions

  • RFC7692 permessage-deflate compression extension support built-in
  • Permessage-deflate operation streams in and out of a user sized buffer for any size compressed or decompressed payload
  • Extension streaming returns to general event loop if waiting for input or needs to wait until connection can accept more output, so many connections can be handled interleaved
  • Generic RFC7692-style extension offer option parsing and management support similifies creating extensions outside the library

Quality

  • Valgrind-clean, Coverity-clean, reliable and robust
  • It's tested against the Autobahn WS Test suite and passes all the relevant tests (See test results)
  • Every commit during development is auto build-tested on Linux, Mac and Windows via Travis and Appveyor

Build sizes

Example .so or .a footprints for 1.7.0-5-gd32bb05
Platform Options .text .rodata .data .bss
Arm Cortex M4 MBED3 Default (server) 22357 4625 1095 8
Arm Cortex A7 Fedora Default (client, server, SSL) 55852 7808 1100 8
x86_64 Fedora Default (client, server, SSL) 58898 7906 1132 12

Free Software

  • The library itself is licensed under LGPL2.1 + static link exception
  • Working example servers + client licensed Public Domain (CC0) intended to be cut-and-pasted into user code for quick start.

Distro packaging

Getting the sources

You can get the latest sources from git

Github or git.libwebsockets.org
git clone https://github.com/warmcat/libwebsockets.git
git clone git://git.libwebsockets.org/libwebsockets

Documentation

Support