uWebsockets.js for FreeBSD
Go to file
Alex Hultman d9a6b1010f App.listen may take host, port, callback now 2019-02-10 11:28:33 +01:00
examples Make pubsub example more interesting 2019-02-09 08:45:51 +01:00
misc Update example cert/key 2019-02-03 15:51:02 +01:00
src App.listen may take host, port, callback now 2019-02-10 11:28:33 +01:00
tests Update for API change: ws.end, ws.close 2019-01-26 17:26:53 +01:00
uWebSockets@02f20bf030 App.listen may take host, port, callback now 2019-02-10 11:28:33 +01:00
.gitmodules Add uWebSockets submodule 2018-11-04 00:11:12 +01:00
.travis.yml Update .travis.yml 2019-02-10 06:33:06 +01:00
LICENSE Apache 2.0 license 2018-11-15 16:01:49 +01:00
Makefile Further MS-DOS madness 2019-01-16 22:19:12 +01:00
README.md v15.1.0 2019-02-10 09:43:53 +01:00

README.md

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

Read more (redirects to C++ project)

For Node.js / NPM users

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

npm install uNetworking/uWebSockets.js#v15.1.0

This project is a Google V8 (Node.js or not) web server built to be efficient and stable. It makes use of µWebSockets, the C++ project, and exposes its features to JavaScript developers. This includes mainly Http & WebSockets, SSL and non-SSL. Prominent users include bitfinex.com, they run ther trading APIs on this server.

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

Recursively clone, and enter, this repo:

git clone --recursive https://github.com/uNetworking/uWebSockets.js.git
cd uWebSockets.js

For Unix (Linux, macOS):

make

For Windows (in an x64 developer terminal):

nmake Windows

Test it out

node examples/HelloWorld.js