uWebSockets README

The project's README from github.com/uNetworking/uWebSockets. As one markdown file: README.md.


Simple, secure1 & standards compliant2 web server for the most demanding3 of applications. Read more...



:closed_lock_with_key: Optimized security

Being meticulously optimized for speed and memory footprint, µWebSockets is fast enough to do encrypted TLS 1.3 messaging quicker than most alternative servers can do even unencrypted, cleartext messaging3.

Furthermore, we partake in Google's OSS-Fuzz with a ~95% daily fuzzing coverage4 with no sanitizer issues. LGTM scores us flawless A+ from having zero CodeQL alerts and we compile with pedantic warning levels.

:arrow_forward: Rapid scripting

µWebSockets is written entirely in C & C++ but has a seamless integration for Node.js backends. This allows for rapid scripting of powerful apps, using widespread competence. See µWebSockets.js.

:crossed_swords: Battle proven

We've been fully standards compliant with a perfect Autobahn|Testsuite score since 20162. µWebSockets powers many of the biggest crypto exchanges in the world, handling trade volumes of multiple billions of USD every day. If you trade crypto, chances are you do so via µWebSockets.

:battery: Batteries included

Designed around a convenient URL router with wildcard & parameter support - paired with efficient pub/sub features for WebSockets. µWebSockets should be the obvious, complete starting point for any real-time web project with high demands.

Start building your Http & WebSocket apps in no time; read the user manual and see examples. You can browse our TypeDoc for a quick overview.

/* One app per thread; spawn as many as you have CPU-cores and let uWS share the listening port */
uWS::SSLApp({

    /* These are the most common options, fullchain and key. See uSockets for more options. */
    .cert_file_name = "cert.pem",
    .key_file_name = "key.pem"
    
}).get("/hello/:name", [](auto *res, auto *req) {

    /* You can efficiently stream huge files too */
    res->writeStatus("200 OK")
       ->writeHeader("Content-Type", "text/html; charset=utf-8")
       ->write("<h1>Hello ")
       ->write(req->getParameter("name"))
       ->end("!</h1>");
    
}).ws<UserData>("/*", {

    /* Just a few of the available handlers */
    .open = [](auto *ws) {
        ws->subscribe("oh_interesting_subject");
    },
    .message = [](auto *ws, std::string_view message, uWS::OpCode opCode) {
        ws->send(message, opCode);
    }
    
}).listen(9001, [](auto *listenSocket) {

    if (listenSocket) {
        std::cout << "Listening on port " << 9001 << std::endl;
    } else {
        std::cout << "Failed to load certs or to bind to port" << std::endl;
    }
    
}).run();

:briefcase: Commercially supported

uNetworking AB is a Swedish consulting & contracting company dealing with anything related to µWebSockets; development, support and customer success.

Don't hesitate sending a mail if you're building something large, in need of advice or having other business inquiries in mind. We'll figure out what's best for both parties and make sure you're not falling into common pitfalls.

Special thanks to BitMEX, Bitfinex, Google, Coinbase, Bitwyre, AppDrag and deepstreamHub for allowing the project itself to thrive on GitHub since 2016 - this project would not be possible without these beautiful companies.

:wrench: Customizable architecture

µWebSockets builds on µSockets, a foundation library implementing eventing, networking and cryptography in three different layers. Every layer has multiple implementations and you control the compiled composition with flags. There are currently five event-loop integrations; libuv, ASIO, GCD and raw epoll/kqueue.

In a nutshell:

See µSockets for an up-to-date list of flags and a more detailed explanation.

:handshake: Permissively licensed

Intellectual property, all rights reserved.

Where such explicit notice is given, source code is licensed Apache License 2.0 which is a permissive OSI-approved license with very few limitations. Modified "forks" should be of nothing but licensed source code, and be made available under another product name. If you're uncertain about any of this, please ask before assuming.

uWebSockets (uNetworking/uWebSockets)

Searching Database…

What is this?μWebSockets is a simple, secure and standards-compliant web server for demanding applications, built as a C++ library — so optimized for speed and memory that its TLS 1.3 encrypted messaging outruns most servers' cleartext.
Is it a server I deploy, or a library I code against?A library you compile into your own application rather than a prebuilt daemon. It builds on μSockets, a foundation library implementing eventing, networking and cryptography in three different layers.
How do I get it running?Build the bundled examples with make, picking backends via compile flags: 'WITHWOLFSSL=1 WITHLIBUV=1 make examples' for WolfSSL plus libuv, or 'WITHOPENSSL=1 make examples' for OpenSSL and the native kernel event loop.
Does it run on Linux only, or on macOS and Windows too?It's cross-platform: the event-loop layer offers raw epoll and kqueue for Linux, the BSDs and macOS, Apple's GCD, plus portable libuv and ASIO builds that also cover Windows.
Is it free to use, even commercially?The source is Apache 2.0, a permissive OSI-approved license with very few limitations, but the README adds an IP notice: forks should consist of nothing but licensed source code and be released under another product name.
Besides WebSockets, what else does it ship with?Per its repo topics it includes an HTTP router, publish/subscribe messaging and proxy-protocol support, so a single process can serve HTTP endpoints and realtime WebSocket traffic together.
Is it battle-tested or experimental?Battle-tested: it has thrived on GitHub since 2016, with the README thanking BitMEX, Bitfinex, Google, Coinbase, Bitwyre, AppDrag and deepstreamHub — crypto exchanges and major tech companies run it in production.
Is there paid support if I'm building something large on it?Yes. uNetworking, a Swedish consulting and contracting company, handles development, support and customer success around μWebSockets and invites mail from anyone building something large or needing advice to avoid common pitfalls.
Where's the full list of build flags?The README points to the separate μSockets repository for an up-to-date list of flags and a more detailed explanation of how to compose the layers.
Size
6.1 MB
Stars
19K
Age
10y
Commits · 90 Days