uWebsockets.js for FreeBSD
Go to file
2019-01-16 21:36:35 +01:00
dist Fix completely broken process.nextTick 2019-01-14 17:16:00 +01:00
examples Wrap res.getWriteOffset, add VideoStreamer example 2019-01-15 11:52:55 +01:00
misc Restructure project 2019-01-15 14:33:43 +01:00
src Small fix for GCC/Clang 2019-01-16 21:36:35 +01:00
uWebSockets@0ca061e772 Wrap res.getWriteOffset, add VideoStreamer example 2019-01-15 11:52:55 +01:00
.gitmodules Add uWebSockets submodule 2018-11-04 00:11:12 +01:00
LICENSE Apache 2.0 license 2018-11-15 16:01:49 +01:00
Makefile Port to Windows 2019-01-16 21:31:17 +01:00
README.md Link to npm install docs 2019-01-15 15:08:48 +01:00

µWebSockets™ (it's "micro") is simple, secure & standards compliant web I/O for the most demanding[1] of applications.

Read more

NPM install

While not physically hosted by NPM, it's still possible to install using NPM tools like so (npm docs):

npm install uNetworking/uWebSockets.js#binaries

Presenting; faster I/O for Node.js

Every other week a new "web framework" pops up for Node.js. Fastify, Restana, Aero, Micro and so on. Most aim to improve I/O performance, but fall flat. You can't fix an inherent design flaw of an entire stack just by slapping a few lines of JavaScript on top.

µWS.js is a 100% C/C++ web platform completely bypassing the entire Node.js I/O stack. JavaScript-exposed functions and objects are entirely backed by native code all the way down to the OS kernel. This makes it possible to reach unprecedented I/O performance from within Node.js (or any stand-alone V8 build). Scroll down for benchmarks.

In a nutshell
const uWS = require('uWebSockets.js');
const port = 3000;

uWS.SSLApp({
  /* cert, key and such specified here, or use uWS.App */
}).get('/whatsmyuseragent', (res, req) => {
  res.writeHeader(
    'content-type', 'text/html; charset= utf-8'
  ).end(
    'Your user agent is: ' + req.getHeader('user-agent')
  );
}).get('/*', (res, req) => {
  res.end('Wildcard route');
}).listen(port, (token) => {
  if (token) {
    console.log('Listening to port ' + port);
  } else {
    console.log('Failed to listen to port ' + port);
  }
});

Streams

Proper streaming of huge data is supported over Http/Https and demonstrated with examples. Here's a shot of me watching real-time streamed HD video from Node.js while simultaneously scoring a 115k req/sec with wrk. For my computer, that's about 5x that of vanilla Node.js (without any HD video streaming/playing).

Benchmarks

Performance retention is about 65% that of the native C++ µWebSockets v0.15. That makes it some 20x as fast as Deno and even faster than most C++-only servers, all from within a JavaScript VM.

Http WebSockets

Build from source

Easiest is to compile yourself a Node.js native addon. The following works for Linux and macOS systems:

git clone --recursive https://github.com/uNetworking/uWebSockets.js.git
cd uWebSockets.js
make
node examples/HelloWorld.js