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…

这是什么?μWebSockets 是一个简单、安全、符合标准的 Web 服务器,以 C++ 库的形式构建,面向高要求的应用——它在速度和内存方面优化得如此极致,以至于其 TLS 1.3 加密消息的速度能超过大多数服务器的明文传输。
它是我要部署的服务器,还是我写代码时用的库?它是一个编译进你自己应用里的库,而不是现成的后台服务。它构建在 μSockets 之上,这是一个基础库,在三个不同的层面实现了事件处理、网络和加密功能。
我怎么把它跑起来?用 make 构建自带的示例,并通过编译标志选择后端:'WITHWOLFSSL=1 WITHLIBUV=1 make examples' 使用 WolfSSL 加 libuv,或者 'WITHOPENSSL=1 make examples' 使用 OpenSSL 和内核原生的事件循环。
它只在 Linux 上运行,还是 macOS 和 Windows 也能用?它是跨平台的:事件循环层为 Linux、BSD 系统和 macOS 提供原生的 epoll 和 kqueue,也提供 Apple 的 GCD,以及可移植的 libuv 和 ASIO 构建,后者同样支持 Windows。
可以免费使用吗,包括商业用途?源码采用 Apache 2.0 许可证,这是一个获得 OSI 认证的宽松许可证,限制非常少。不过 README 中附加了一条知识产权说明:分支(fork)应当只包含获得许可的源码,并以另一个产品名称发布。
除了 WebSockets,它还自带哪些功能?根据其仓库的主题标签,它包含一个 HTTP 路由器、发布/订阅消息以及代理协议(proxy protocol)支持,因此单个进程可以同时提供 HTTP 接口和实时 WebSocket 流量。
它是久经考验的,还是实验性质的?久经考验:它自 2016 年起就在 GitHub 上蓬勃发展,README 中感谢了 BitMEX、Bitfinex、Google、Coinbase、Bitwyre、AppDrag 和 deepstreamHub——加密货币交易所和大型科技公司都在生产环境中使用它。
如果我要在上面构建一个大型项目,有付费支持吗?有。uNetworking 是一家瑞典的咨询与承包公司,负责 μWebSockets 的开发、支持和客户服务,并欢迎正在构建大型项目或需要建议以避开常见陷阱的人发邮件联系。
完整的构建标志列表在哪里?README 指向单独的 μSockets 仓库,那里有最新的标志列表,以及对如何组合各个层的更详细说明。
Size
6.1 MB
Stars
19K
Age
10y
Commits · 90 Days